| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import { queryMyWRPosition } from "../../../services/api/orders/index";
- // moduleMine/pages/myinventorys/myinventorys.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// tab激活索引
- active: 0,
- /// tabs
- tabs: [{id: 1, name: '单颗裸钻'},
- {id: 2, name: '钻石首饰'},
- {id: 3, name: '彩色钻石'}],
- /// 列头
- titles: ['形状', '价格', '克拉单价', '颜色', '净度', '克拉重量', '冻结重量'],
- /// 查询数据
- datas: [{}],
- /// 数据是否为空
- isEmpty: false
- },
- /**
- * tab触发事件
- */
- onTabChange(e: any) {
- /// 设置激活项
- this.setData({
- active: e.detail.index
- })
- switch (e.detail.index) {
- case 0 || 2: /// 单颗裸钻 彩色钻石
- this.setData({
- /// 列头
- titles: ['形状', '价格', '克拉单价', '颜色', '净度', '克拉重量', '冻结重量'],
- active: e.detail.index
- })
- break;
- default: /// 首饰
- this.setData({
- /// 列头
- titles: ['主石形状', '款式', '价格', '主石颜色', '主石净度', '主石切工', '主石重量'],
- active: e.detail.index
- })
- break;
- }
- /// 查询我的库存
- this.queryMyWRPosition(e.detail.index+1)
- },
- /// 查询我的库存
- queryMyWRPosition(zscategory: number) {
- /// loding
- wx.showLoading({ title: '数据请求中' })
- /// 查询我的库存
- queryMyWRPosition({
- data: {
- zscategory: zscategory,
- wruserid: wx.getStorageSync('UserId')
- },
- success: (res) => {
- console.log(res)
- /// 请求失败
- if (res.code != 200) {
- wx.showToast({ icon: 'error', title: '请求失败,原因:'+res.msg })
- return
- }
- /// 设置数据
- this.setData({
- /// 数据信息
- datas: res.data,
- isEmpty: res.data.length == 0
- })
- },
- fail: () => {
- wx.showToast({title: '查询失败', icon: 'error'})
- },
- complete: () => {
- wx.hideLoading()
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- /// 查询我的库存
- this.queryMyWRPosition(1)
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- /// 查询我的库存
- this.queryMyWRPosition(this.data.active+1)
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|