| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- var _self;
- export const orderOperate = {
- data() {
- return {
- // 主题色
- appThemeColor: this.$appTheme.appThemeColor
- }
- },
- onload(){
- _self = this;
- },
- methods: {
- // 去付款
- goPay(e) {
- console.log(e);
- // return;
- this.$u.api.payAjax(e.order_no).then(({code,data})=>{
- if(code==1){
- var orderInfos = data;
- uni.requestPayment({
- "provider": "wxpay",
- "orderInfo":orderInfos,
- ...data,
- success: function(res) {
- uni.showToast({
- title: "支付成功",
- icon: 'success',
- success: () => {
- setTimeout(() => {
- uni.redirectTo({
- url: '/pages-mall/pages/order/pay-result?payTotal='+e.total_amount+'&orderId='+e.order_no
- })
- }, 500)
- // _self.subScribeMsg(e);
- }
- })
- },
- fail: function(err) {
- uni.showModal({
- content:'支付失败,请到我的订单中,重新支付',
- success() {
- // +this.orderInfo.order_no,
- // uni.redirectTo({
- // url:'/pages-mall/pages/order/detail'
- // })
- }
- })
- }
- });
- }
- })
- },
- // 支付回调
- subScribeMsg(e) {
- uni.getSetting({
- withSubscriptions: true,
- success(res) {
- console.log('1', res, '订阅信息', res.subscriptionsSetting);
- if (!res.subscriptionsSetting.mainSwitch) {
- uni.openSetting({ //打开设置页
- success(res) {
- console.log('打开设置页', res.authSetting);
- }
- })
- } else {
- uni.requestSubscribeMessage({
- tmplIds: ['Sfa68XDGAUQveX50PcP_Ep6ngNz3luvXJNwzASjzzvQ',
- '_VxaYVnVTj3aG_wengF8KNFDI3WRhOrFseBerx8xvXE',
- ],
- success(res) {
- console.log('requestSubscribeMessage 订阅信息', res);
- if (res['Sfa68XDGAUQveX50PcP_Ep6ngNz3luvXJNwzASjzzvQ'] == "accept") { // 用户点击确定后
- console.log('用户订阅点击确定按钮');
- // _self.getSubMsg()
- } else {
- console.log('拒绝');
- }
- },
- fail(errMessage) {
- console.log("订阅消息 失败 ", errMessage);
- },
- // 不管成功或失败都要执行
- complete() {
- // if (_self.ordercode == null) return _self.getOrder();
- // if (_self.ordercode != null) return _self.getPayOrder();
- setTimeout(() => {
- uni.redirectTo({
- url: '/pages-mall/pages/order/pay-result?payTotal='+e.total_amount
-
- })
- }, 500)
- }
- })
- }
- },
- })
- },
-
- // 查看详情
- goOrderInfo(id) {
- // uni.setStorageSync('orderInfo', this.data);
- uni.navigateTo({
- url: '/pages-mall/pages/order/detail?order_id='+id
- });
-
- },
- // 取消订单
- cancelOrder(id,page) {
- let _self = this;
- uni.showModal({
- title: '提示',
- content: '是否取消当前订单?',
- confirmColor: this.appThemeColor,
- success: function(res) {
- if (res.confirm) {
- // TODO 接口
- _self.$u.api.cancelOrderAjax(id).then(({code,data})=>{
- if(code==1){
- _self.$u.toast('取消成功');
- // uni.redirectTo({
- // url:'/pages-mall/pages/order/list'
- // });
- _self.$emit('refresh')
- /* // uni.reload();
- // if(page=='orderList'){
- // // 从订单列表过来的,刷新订单列表
- // uni.reload();
- // _self.$router.go(0);
- // } */
- }
- }).catch(()=>{
- // _self.$router.go(0);
-
- })
- }
- }
- });
- },
- // 提醒发货
- pushDelivery() {
- return;
- uni.showModal({
- title: '提示',
- content: '是否对当前订单提醒发货?',
- confirmColor: this.appThemeColor,
- success: function(res) {
- if (res.confirm) {
- // TODO 接口
- }
- }
- });
- },
- // 查看物流
- goExpress(orderInfo) {
- // uni.setStorageSync('orderInfo', this.data);
- uni.navigateTo({
- url: '/pages-mall/pages/order/express?orderInfo='+encodeURIComponent(JSON.stringify(orderInfo))
- })
- },
- // 申请售后
- applyAfterSales(orderId) {
- // console.log(data);
- // return;
- uni.navigateTo({
- url: '/pages-mall/pages/after-sales/apply?orderId='+orderId
- })
- },
-
- // 确认收货
- confirmReceipt(data) {
- console.log(data);
- let _self = this;
- uni.showModal({
- title: '提示',
- content: '是否确认收货?',
- confirmColor: this.appThemeColor,
- success: function(res) {
- if (res.confirm) {
- // TODO 接口
- let ids = [];
- data.order_details.forEach(e=>{
- ids.push(e.id);
- });
- /* console.log({
- order_id:data.id,
- order_detail_ids:ids.toString()
- })
- return false; */
- _self.$u.api.orderConfirmAjax({
- order_id:data.id,
- order_detail_ids:ids.toString()
- }).then(({code,data})=>{
- if(code==1){
- _self.$emit('refresh')
- }
- }).catch(()=>{
- _self.$u.toast('操作失败')
- })
- }
- }
- });
- },
- // 去评价
- goEvaluate() {
- uni.setStorageSync('orderInfo', this.data);
- uni.navigateTo({
- url: '/pages-mall/pages/evaluate/add'
- })
- },
- // 删除记录
- deleteOrder() {
- uni.showModal({
- title: '提示',
- content: '是否删除当前订单?',
- confirmColor: this.appThemeColor,
- success: function(res) {
- if (res.confirm) {
- // TODO 接口
- }
- }
- });
- },
-
- // 售后详情
- afterSalesDetail(id){
- uni.navigateTo({
- url: '/pages-mall/pages/after-sales/apply-status?id='+id
- })
- // uni.navigateTo({
- // url: '/pages-mall/pages/after-sales/apply-status?applyInfo='+encodeURIComponent(JSON.stringify(data))
- // })
- },
- // 查看退款详情
- goBackMoney() {
- uni.setStorageSync('orderInfo', this.data);
- uni.navigateTo({
- url: '/pages-mall/pages/after-sales/back'
- })
- }
- }
- }
|