| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import { queryMyFavorite } from "../../services/api/orders/index"
- import Toast from '@vant/weapp/toast/toast';
- import { clientType, isEncrypted, marketid, protoHeader, userid, timetample } from "../../services/utils";
- import { sendMsgToMQ } from "../../services/api/common/index";
- import { FunCode } from "../../constants/enum/funcode";
- // pages/circle/circle.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// 窗口高度
- windowHeight: getApp().globalData.windowHeight,
- /// tabs
- tabs: [{id: 2, name: '单颗裸钻'}, {id: 5, name: '单颗彩钻'}],
- /// tab索引
- active: 0,
- /// 列头
- titles: [['重量', '形状', '尺寸', '编号'],
- ['颜色', '净度', '切工', '对称', '抛光', '荧光', '证书', '价格']],
- /// 我的收藏
- favorites: <GuangZuan.MyFavorite[]>[],
- /// 是否空数据
- isEmpty: true
- },
- /**
- * tab触发事件
- */
- onTabChange(e: any) {
- this.setData({ active: e.detail.index })
- /// 查询数据
- this.queryMyFavorite()
- },
- /**
- * 按钮点击事件
- */
- onButtonPressed(e: any) {
- console.log(e)
- /// 页面跳转
- wx.navigateTo({
- url: '/mCircle/pages/contrast/contrast'
- })
- },
-
- /**
- * tab触发事件
- */
- onCancelFavorite(e: any) {
- /// loding.....
- Toast.loading({ message: '请求中.....'})
-
- const wrtradeorderid = this.data.favorites[e.target.id].wrtradeorderid
- /// 参数信息
- const info = {
- UserID: userid(),
- OperateType: 2,
- ClientType: clientType(),
- MarketID: marketid(),
- ClientSerialNo: timetample().toString(),
- WRTradeOrderID: wrtradeorderid,
- Header: protoHeader(FunCode.GoodsFavoriteOperateReq)
- }
- /// 发送请求
- sendMsgToMQ({
- data: {
- data: JSON.stringify(info),
- funCodeReq: FunCode.GoodsFavoriteOperateReq,
- funCodeRsp: FunCode.GoodsFavoriteOperateRsp,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- /// 操作失败
- if (res.code != 0) {
- Toast.fail({message: '请求失败,原因:'+res.msg})
- return
- }
- console.log(res)
- /// 操作成功
- Toast.success({message: '请求成功'})
- /// 更新数据
- this.queryMyFavorite()
- },
- fail: (emsg) => {
- /// 操作失败
- Toast.fail({ message: '请求失败,原因:'+emsg})
- }, complete: () => {}
- })
- },
- /// 查询我的收藏数据信息
- queryMyFavorite() {
- /// loding.....
- Toast.loading({message: '加载中...'});
- /// 发送查询
- queryMyFavorite({
- data: {
- userid: userid(),
- zscategorys: this.data.active == 0 ? '2' : '5'
- },
- /// 加载成功
- success: (res) => {
- if (res.code != 200) {
- /// 加载失败
- Toast.fail({ message: '加载失败...'});
- return
- }
- /// 数据赋值
- this.setData({
- favorites: res.data,
- isEmpty: res.data.length == 0
- })
- },
- fail: (emsg) => {
- /// 加载失败
- Toast.fail({ message: '加载失败...'+emsg});
- },
- complete: () => {}
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- /// 查询数据
- this.queryMyFavorite()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getTabBar().init()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- /// 查询数据
- this.queryMyFavorite()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|