Browse Source

市场活动优化操作

xiaohaizhao 2 years ago
parent
commit
75f273d189

+ 25 - 21
packageA/activity/addActivity.js

@@ -3,7 +3,9 @@ const _Http = getApp().globalData.http,
 
 Page({
     data: {
+        loading: false,
         showAll: false,
+        disabled: true,
         form: [{
             label: "活动类型",
             error: false,
@@ -77,16 +79,12 @@ Page({
             "director": "",
             "address": "",
             "type": "",
-            "enddate":'',
-            "begdate":""
-        },
-        disabled: true
+            "enddate": '',
+            "begdate": ""
+        }
     },
     onLoad(options) {
         if (options.rowData) {
-            // wx.setNavigationBarTitle({
-            //   title: 'title',
-            // })
             let data = JSON.parse(options.rowData);
             this.setData({
                 disabled: false,
@@ -103,33 +101,39 @@ Page({
         }
     },
     submit() {
+        this.setData({
+            loading: true
+        })
         let content = {
             ...this.data.content,
             ...this.selectComponent("#Form").submit()
         };
-        if(content.enddate === undefined) content.enddate = ''
+        if (!content.enddate) content.enddate = '';
         _Http.basic({
             "classname": "webmanage.saletool.orderclue.ordercluecampaign",
             "method": "insertormodify_campaign",
             "version": 1,
             content
         }).then(res => {
-            console.log("添加普通报价单", res)
+            this.setData({
+                loading: false
+            })
+            console.log("添加市场活动", res)
             wx.showToast({
                 title: res.msg != '成功' ? res.msg : '保存成功',
-                icon: "none"
+                icon: "none",
+                mask: true
             })
-            if (res.msg != '成功') return;
-            setTimeout(() => {
-                wx.navigateBack();
-                getCurrentPages().forEach(v => {
-                    console.log(v, '路径');
-                    if (v.__route__ == 'packageA/activity/detail') {
-                        v.getDetail();
-                    } else if (v.__route__ == 'packageA/activity/index') {
-                        v.getList(true);
-                    }
-                })
+            if (res.msg == '成功') setTimeout(() => {
+                const page = getCurrentPages()[getCurrentPages().length - 2];
+                if (page.__route__ == 'packageA/activity/detail') {
+                    page.getDetail();
+                    wx.navigateBack();
+                } else if (page.__route__ == 'packageA/activity/index') {
+                    wx.redirectTo({
+                        url: '/packageA/activity/detail?id=' + res.data.sat_campaignid,
+                    })
+                }
             }, 300)
         })
     },

+ 1 - 1
packageA/activity/addActivity.wxml

@@ -2,5 +2,5 @@
 <Yl_field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' bind:interrupt="interrupt" />
 <view style="height: 100rpx;" />
 <view class="new-footer">
-    <van-button custom-class='new-submit' disabled='{{disabled}}' bindclick='submit'>提交</van-button>
+    <van-button custom-class='new-submit' disabled='{{disabled || loading}}' loading='{{loading}}' bindclick='submit'>提交</van-button>
 </view>

+ 21 - 15
packageA/activity/detail.js

@@ -48,14 +48,13 @@ Page({
     },
     onLoad(options) {
         this.setData({
-            sat_campaignid: options.sat_campaignid,
+            sat_campaignid: options.id,
             isAdmin: wx.getStorageSync('auth').wmarketing_activity.options.some(v => v == "admin"), //是否具有管理权限
             options: wx.getStorageSync('auth').wmarketing_activity.options, //权限列表
         });
         this.getDetail();
     },
     getDetail() {
-        console.log(111);
         _Http.basic({
             "classname": "webmanage.saletool.orderclue.ordercluecampaign",
             "method": "queryCampaignMain",
@@ -222,12 +221,7 @@ Page({
                                 title: res.msg == '成功' ? `已发布该活动` : res.msg,
                                 icon: "none"
                             });
-                            if (res.msg == '成功') {
-                                this.getDetail()
-                                let pages = getCurrentPages(),
-                                    page = pages[pages.length - 2]
-                                page.getList(true)
-                            }
+                            if (res.msg == '成功') this.getDetail()
                         })
                     }
                 })
@@ -278,9 +272,7 @@ Page({
                                 title: res.msg == '成功' ? `已取消该活动` : res.msg,
                                 icon: "none"
                             });
-                            if (res.msg == '成功') {
-                                this.getDetail()
-                            }
+                            if (res.msg == '成功') this.getDetail()
                         })
                     }
                 })
@@ -324,13 +316,27 @@ Page({
                     setTimeout(() => {
                         that.getDetail();
                         wx.navigateBack();
-                        /*  getCurrentPages().forEach(v => {
-                             if (['packageA/project/index'].includes(v.__route__)) v.getList(true)
-                         }) */
                     }, 300)
                 })
             }
         })
     },
-    onShareAppMessage() {}
+    onUnload() {
+        const page = getCurrentPages().find(v => v.__route__ == 'packageA/activity/index');
+        if (!page) return;
+        let content = JSON.parse(JSON.stringify(page.data.content));
+        content.pageSize = (content.pageNumber - 1) * content.pageSize;
+        content.pageNumber = 1;
+        _Http.basic({
+            "classname": "webmanage.saletool.orderclue.ordercluecampaign",
+            "method": "insertormodify_campaign",
+            "version": 1,
+            content
+        }).then(res => {
+            console.log("更新市场活动列表");
+            if (res.msg == '成功') page.setData({
+                list: res.data
+            })
+        })
+    }
 })

+ 1 - 1
packageA/activity/modules/list/index.wxml

@@ -1,5 +1,5 @@
 <!--packageA/activity/modules/list/index.wxml-->
-<navigator class="offer-list" url="/packageA/activity/detail?sat_campaignid={{item.sat_campaignid}}" wx:for="{{list}}" wx:key="sat_campaignid">
+<navigator class="offer-list" url="/packageA/activity/detail?id={{item.sat_campaignid}}" wx:for="{{list}}" wx:key="sat_campaignid">
     <view class="title">
         <text class="line-1">{{item.name}}</text>
         <view class="status" style="background-color: {{backColor.getColor(item.status)}};">{{item.status}}</view>