123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- // pages/welfareMall/order/orderCompletion.js
- import WelfareMall from '../../../api/welfareMall'
- import { parseTime } from '../../../utils/util'
- import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- page: 1,
- pageSize: 10,
- lock: false,
- noResult: false,
- noMore: false,
- isLogin: false,
- orderDetail: null,
- orderSn: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- that.orderSn = options.ordersn
- this.setData({
- isLogin: getMobileCache() != '',
- orderSn: options.ordersn,
- })
- if(this.data.isLogin){
- this.getOrder(that.orderSn);
- this.data.orderSn = options.ordersn;
- }
- },
- // 订单数据
- getOrder: function(data) {
- WelfareMall.getOrder({
- mobile: getMobileCache(),
- orderSn: data,
- }).then(res => {
- if (res.code == 200) {
- this.userOrderistView(res.data)
- }
- this.data.lock = false
- }).catch(_ => {
- console.log(_)
- this.data.lock = false
- })
- },
- userOrderistView: function(data) {
- if (!data) {
- console.log("订单详情数据为空");
- return
- }
- //对象转换
- this.data.orderDetail = data
- this.setData({
- mobileTop:getMobileCache(),
- orderDetail: this.data.orderDetail
- })
- },
- // 取消订单
- toCancelOrder(e) {
- wx.showModal({
- title: '取消订单',
- content: '',
- showCancel: true,//是否显示取消按钮
- cancelText:"取消",//默认是“取消”
- cancelColor:'black',//取消文字的颜色
- confirmText:"确定",//默认是“确定”
- confirmColor: 'black',//确定文字的颜色
- success: res => {if (res.cancel) {
- //点击取消,默认隐藏弹框
- } else {
- //点击确定
- WelfareMall.cancelOrder({
- mobile: getMobileCache(),
- orderSn: this.data.orderSn,
- }).then(res => {
- if (res.code == 200) {
- wx.showToast({
- title: '取消订单成功',
- icon: 'none',
- duration: 1500
- })
- }
- this.data.lock = false
- }).catch(_ => {
- console.log(_)
- this.data.lock = false
- })
- }
- },
- fail: function (res) {
- console.log(res)
- },//接口调用失败的回调函数
- })
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|