xcx/pages/cart/cart.js

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

// pages/cart/cart.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hostUrl: app.globalData.hostUrl,
    selection: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var userId = wx.getStorageSync('userId');
    if (userId != null && userId > 0 && userId != '') {
      that.getCartList();//读取购物车
      that.dTotal();//读取金额
      that.getCountChecked(function(data){});//读取全选状态
    } else {
      wx.showModal({
        title: '温馨提示',
        content: '先登录',
        success: function (res) {
          if (res.confirm) {
            wx.navigateTo({
              url: '/pages/mine/mine',
            })
          } else if (res.cancel) {
          }
        }
      })
    }
  },
  getCartList: function () {//读取购物车
    var that = this;
    wx.request({
      url: app.globalData.apiUrl,
      data: {
        opt: 'getCartList',
        userId: wx.getStorageSync('userId'),
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        if (res.data != null) {
          that.setData({
            cartList: res.data,
          })
        }
      }
    })
  },
  dTotal: function () {//读取金额
    var that = this;
    wx.request({
后面还有 276 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。