123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- // pages/order-detail/order-detail.js
- var http = require('../../utils/http.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- orderItemDtos: [],
- remarks: "",
- actualTotal: 0,
- userAddrDto: null,
- orderNumber: "",
- createTime: "",
- status: 0,
- productTotalAmount: '',
- transfee: '',
- reduceAmount: '',
- shopId: '',
- prodid: ''
- },
- //跳转商品详情页
- toProdPage: function(e) {
- var prodid = e.currentTarget.dataset.prodid;
- wx.navigateTo({
- url: '/pages/prod/prod?prodid=' + prodid,
- })
- },
- /**
- * 加入购物车
- */
- addToCart: function(event) {
- let index = event.currentTarget.dataset.index
- // if (!this.orderItemDtos) {
- // console.log(1213)
- // return;
- // }
- var ths = this;
- wx.showLoading({
- mask: true
- });
- var params = {
- url: "/p/shopCart/changeItem",
- method: "POST",
- data: {
- basketId: 0,
- count: this.data.orderItemDtos[index].prodCount,
- prodId: this.data.orderItemDtos[index].prodId,
- shopId: this.data.shopId,
- skuId: this.data.orderItemDtos[index].skuId
- },
- callBack: function(res) {
- //console.log(res);
- wx.hideLoading();
- wx.showToast({
- title: "加入购物车成功",
- icon: "none"
- })
- wx.switchTab({
- url: '/pages/basket/basket',
- })
- }
- };
- http.request(params);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- this.loadOrderDetail(options.orderNum);
- },
- /**
- * 加载订单数据
- */
- loadOrderDetail: function(orderNum) {
- var ths = this;
- wx.showLoading();
- //加载订单详情
- var params = {
- url: "/p/myOrder/orderDetail",
- method: "GET",
- data: {
- orderNumber: orderNum
- },
- callBack: function(res) {
- ths.setData({
- orderNumber: orderNum,
- actualTotal: res.actualTotal,
- userAddrDto: res.userAddrDto,
- remarks: res.remarks,
- orderItemDtos: res.orderItemDtos,
- createTime: res.createTime,
- status: res.status,
- productTotalAmount: res.orderItemDtos[0].productTotalAmount,
- transfee: res.transfee,
- reduceAmount: res.reduceAmount,
- actualTotal: res.actualTotal,
- shopId: res.shopId
- });
- wx.hideLoading();
- }
- };
- http.request(params);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- },
- // 一键复制事件
- copyBtn: function(e) {
- var ths = this;
- wx.setClipboardData({
- //准备复制的数据
- data: ths.data.orderNumber,
- success: function(res) {
- wx.showToast({
- title: '复制成功',
- });
- }
- })
- },
- })
|