paydetail.js 5.0 KB
var t = require("../../../utils/network.js");

Page({
    data: {
        info: [],
        type: "",
        id: "",
        goods: [],
        num: ""
    },
    onLoad: function(t) {
        var a = this;
        wx.getStorage({
            key: "ouid",
            success: function(t) {
                a.setData({
                    ouid: t.data
                });
            }
        }), this.setData({
            id: t.id,
            type: t.type,
            num: t.num
        }), this.getdetial();
    },
    getdetial: function() {
        var a = this;
        t.POST({
            url: "User/detail_order",
            header: "application/x-www-form-urlencoded",
            params: {
                id: this.data.id
            },
            success: function(t) {
                console.log(t), a.setData({
                    info: t.data.info,
                    goods: t.data.details
                });
            }
        });
    },
    pay_order: function(a) {
     let i=0;
     let  e = a.currentTarget.dataset.id;
     let o = this.data.goods;
     for (let n = 0; n < o.length; n++){
      i += parseInt(o[n].count)* o[n].pprice;
     } 
        console.log('jiage',i);
        t.POST({
            url: "Pay/pay_order",
            header: "application/x-www-form-urlencoded",
            params: {
                ouid: this.data.ouid,
                oid: e,
                money: i
            },
            success: function(t) {
                t.data && wx.requestPayment({
                    timeStamp: t.data.timeStamp,
                    nonceStr: t.data.nonceStr,
                    package: t.data.package,
                    signType: t.data.signType,
                    paySign: t.data.paySign,
                    success: function(t) {
                        wx.redirectTo({
                            url: "../../my/delivery/delivery"
                        });
                    },
                    fail: function(t) {}
                });
            }
        });
    },
    pay_order2: function(a) {
        var e = this, o = a.currentTarget.dataset.id;
        this.data.info;
        wx.showModal({
            title: "确认收货",
            content: "确定已经收到货?",
            success: function(a) {
                a.confirm ? t.POST({
                    url: "User/order_finish",
                    header: "application/x-www-form-urlencoded",
                    params: {
                        ouid: e.data.ouid,
                        id: o
                    },
                    success: function(t) {
                        "success" == t.data.state ? (wx.showToast({
                            title: t.data.msg,
                            icon: "success"
                        }), wx.navigateBack({
                            delta: 1
                        })) : wx.showToast({
                            title: t.data.msg,
                            icon: "none"
                        });
                    }
                }) : a.cancel;
            }
        });
    },
    onReady: function() {},
    del_order: function(a) {
        var e = a.currentTarget.dataset.id;
        this.data.info;
        t.POST({
            url: "User/del_order",
            header: "application/x-www-form-urlencoded",
            params: {
                ouid: this.data.ouid,
                id: e
            },
            success: function(t) {
                wx.showLoading({
                    title: "处理中..."
                }), "success" == t.data.state ? (wx.hideLoading(), wx.redirectTo({
                    url: "../../my/completed/completed"
                })) : wx.showLoading({
                    title: "处理中..."
                });
            },
            fail: function(t) {}
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
 onShareAppMessage: function (options) {
  let that = this;
  let ouid;
  // 设置菜单中的转发按钮触发转发事件时的转发内容
  var shareObj = {
   title: '嗒咕商场', // 默认是小程序的名称(可以写slogan等)
   path: '/pages/start/start?share_id=' + wx.getStorageSync('ouid'), // 默认是当前页面,必须是以‘/’开头的完整路径
   imgUrl: '',//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
   success: function (res) {
    // 转发成功之后的回调
    if (res.errMsg == 'shareAppMessage:ok') { }
   },
   fail: function () {
    // 转发失败之后的回调
    if (res.errMsg == 'shareAppMessage:fail cancel') {
     // 用户取消转发
    } else if (res.errMsg == 'shareAppMessage:fail') {
     // 转发失败,其中 detail message 为详细失败信息
    }
   },
   complete: function () {
    // 转发结束之后的回调(转发成不成功都会执行)
   }
  }
  return shareObj;
 },
});