Преглед изворни кода

会员端,支付方式默认选中Paystack

theo пре 3 година
родитељ
комит
84f4d4f45a

+ 1 - 1
frontendEle/src/views/shop/order.vue

@@ -473,7 +473,7 @@ export default{
         }
 
         // 支付方式的第一项默认选中
-        this.payType = Object.values(this.payList)[0]['label']
+        this.payType = Object.values(this.payList)[1]['label']
         // 免运费阈值
         this.freeShipping = response.freeShipping
         // 运费

+ 1 - 1
frontendEle/src/views/user/dec.vue

@@ -489,7 +489,7 @@ export default {
         // 支付方式
         this.payList = response.sellType[0]['sell_type']
         // 支付方式的第一项默认选中
-        this.form.payType = Object.values(this.payList)[0]['label']
+        this.form.payType = Object.values(this.payList)[1]['label']
       })
     },
     handleCurrentChange (val) {

+ 347 - 349
frontendEle/src/views/user/upgrade.vue

@@ -237,368 +237,366 @@
 </template>
 
 <script>
-    import Vue from 'vue'
-    import network from '@/utils/network'
-    import baseInfo from '@/utils/baseInfo'
-    import store from '@/utils/vuexStore'
-    import tool from '@/utils/tool'
-    import userInfo from '@/utils/userInfo'
-    import { PAY_STACK_PUBLIC_KEY, PAY_STACK_CURRENCY } from '@/utils/config'
-    import paystack from 'vue-paystack'
+import Vue from 'vue'
+import network from '@/utils/network'
+import baseInfo from '@/utils/baseInfo'
+import store from '@/utils/vuexStore'
+import tool from '@/utils/tool'
+import userInfo from '@/utils/userInfo'
+import { PAY_STACK_PUBLIC_KEY, PAY_STACK_CURRENCY } from '@/utils/config'
+import paystack from 'vue-paystack'
 
-    export default {
-        name: 'user_upgrade',
-        mounted() {
-            this.getData()
-        },
-        computed:{
-            _tableData(){
-                if(this.tableData==null){
-                    return [];
-                }
-                if(this.form.decLv==''){
-                    return this.tableData;
-                }
-                return this.tableData.filter(item=>{
-                    return item.LEVEL_ID == this.form.decLv
-                })
-            },
-            reference() {
-                let text = "";
-                let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-                for (let i = 0; i < 10; i++)
-                    text += possible.charAt(Math.floor(Math.random() * possible.length));
-                return text;
-            }
-        },
-
-        data() {
-            return {
-                nowPerf:'',
-                nextPerf:'',
-                decUserName:'',
-                needDiffPv:'',
-                isMax:true,
-                upgradeOption:[],
-                toLevel:'',
-                currentRow:null,
-                decWay:'2',
-                regionData: store.state.regionInfo.regionData,
-                form: {
-                    address:'',
-                    areaSelected:[],
-                    consignee:'',
-                    upgradeFunc:'',
-                    upgradeValue:'',
-                    addAt:'',
-                    userRealName:'',
-                    userDecName:'',
-                    remark:'',
-                    realName:'',
-                    decLv: '',
-                    insertUserName:'',
-                    decUserName:'',
-                    recUserName:'',
-                    conUserName:'',
-                    insertUserIdCard:'',
-                    packageId:'',
-                    goodsId:[],
-                    goodsNum:[],
-                    province:'',
-                    // city:'',
-                    // county:'',
-                    lgaName:'',
-                    cityName:'',
-                    acceptMobile:'',
-                    payType: '',
-                },
-                num: 1,
-                tableData:null,
-                tableDatas:null,
-                allDecPackage:{},
-                loading: false,
-                submitButtonStat: false,
-                submitButton:false,
-                allGoods:[],
-                multipleSelection: [],
-                goodsNums:[],
-                numList: [],
-                sell_price_sum:0.00,
-                price_pv_sum:0.00,
-                payList: [],
-                sn: '',
-                payDialog: false,
-                countdown: 5,
-                visible: false,
-                payStackLoading: false,
-                channels: ["card", "bank", "ussd", "qr"], // eft(南非)  mobile_money(加纳)
-                PayStackForm: {
-                    publicKey: PAY_STACK_PUBLIC_KEY,
-                    currency: PAY_STACK_CURRENCY,
-                    firstname: userInfo.userName(),
-                    lastname: '',
-                    email: userInfo.userEmail(),
-                    amount: 0,  // kobo
-                    orderSn: '',
-                    metadata: {
-                        cart_id: this.sn,
-                        custom_fields: [
-                            {
-                                display_name: 'orderSn',
-                                variable_name: 'orderSn',
-                                value: this.sn
-                            },
-                        ]
-                    },
-                },
-            }
-        },
-        components: {
-            paystack
-        },
-        methods: {
-            // 获取要升级的会员信息
-            upgradeInfo() {
-                if (this.form.insertUserName) {
-                    network.postData(`user/upgrade-info`,{userName:this.form.insertUserName}).then(response => {
-                        this.form.addAt=response.baseInfo.ADD_AT
-                        this.form.userRealName=response.baseInfo.REAL_NAME
-                        this.form.userDecName=response.baseInfo.DEC_NAME
-                        this.isMax = response.baseInfo.IS_MAX
-                        this.upgradeOption = response.baseInfo.LEVEL_LIST
-                        this.form.upgradeFunc = response.baseInfo.UPGRADE_FUNC //upgradeFunc升级方式
-                        this.nowPerf = response.baseInfo.NOW_PERF // 用户当前业绩
-                        this.nextPerf = response.baseInfo.NEXT_PERF
-                    })
-                }
-            },
-            changeLevel(data) {
-                let { value,diffPv } = data
-                this.needDiffPv = diffPv
-                this.toLevel = value
-            },
-            getSum(){
-                let sell_price_sum=0,price_pv_sum=0;
-                this.multipleSelection.map((item,index)=>{
-                    sell_price_sum+=Number(item.SELL_PRICE)*item.goodsNum;
-                    price_pv_sum+=Number(item.PRICE_PV)*item.goodsNum;
-                })
-                this.sell_price_sum=tool.formatPrice(sell_price_sum);
-                this.price_pv_sum=tool.formatPrice(price_pv_sum);
-            },
-            getData () {
-                network.getData(`user/upgrade`).then(response => {
-                    this.decUserName = response.decUserName
-                    this.loading = false;
-                    this.allDecPackage = response.allDecPackage;
-                    this.allGoods = response.allGoods;
-                    let settingObj=this.allDecPackage;
-                    let settingArr = Object.keys(settingObj).map(key => {
-                        //console.log(key); //为每个键名
-                        return settingObj[key];  //把每个对象返回出去生成一个新的数组中相当于0:{id:1}
-                    });
-                    this.tableData=settingArr;
-                    let settingObj1=this.allGoods;
-                    for(let i in settingObj1){
-                        this.numList[i] = 1;
-                        settingObj1[i].goodsNum= 1 ;
-                    }
-                    this.tableDatas=settingObj1;
-
-                  // 支付方式
-                  this.payList = response.sellType[0]['sell_type']
-                  // 支付方式的第一项默认选中
-                  this.form.payType = Object.values(this.payList)[0]['label']
-                }).catch(() => {
-                });
-            },
-            handleCurrentChange(val) {
-                console.log(val)
-                if(!val){return}
-                this.currentRow = val;
-                this.form.packageId=this.currentRow.ID;
+export default {
+  name: 'user_upgrade',
+  mounted () {
+    this.getData()
+  },
+  computed: {
+    _tableData () {
+      if (this.tableData == null) {
+        return [];
+      }
+      if (this.form.decLv === '') {
+        return this.tableData;
+      }
+      return this.tableData.filter(item => {
+        return item.LEVEL_ID === this.form.decLv
+      })
+    },
+    reference() {
+      let text = '';
+      let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+      for (let i = 0; i < 10; i++)
+        text += possible.charAt(Math.floor(Math.random() * possible.length));
+      return text;
+    }
+  },
 
-                console.log(this.form.packageId)
+  data () {
+    return {
+      nowPerf: '',
+      nextPerf: '',
+      decUserName: '',
+      needDiffPv: '',
+      isMax: true,
+      upgradeOption: [],
+      toLevel: '',
+      currentRow: null,
+      decWay: '2',
+      regionData: store.state.regionInfo.regionData,
+      form: {
+        address: '',
+        areaSelected:[],
+        consignee: '',
+        upgradeFunc: '',
+        upgradeValue: '',
+        addAt: '',
+        userRealName: '',
+        userDecName: '',
+        remark: '',
+        realName: '',
+        decLv: '',
+        insertUserName: '',
+        decUserName: '',
+        recUserName: '',
+        conUserName: '',
+        insertUserIdCard: '',
+        packageId: '',
+        goodsId:[],
+        goodsNum:[],
+        province: '',
+        // city: '',
+        // county: '',
+        lgaName: '',
+        cityName: '',
+        acceptMobile: '',
+        payType: '',
+      },
+      num: 1,
+      tableData: null,
+      tableDatas: null,
+      allDecPackage: {},
+      loading: false,
+      submitButtonStat: false,
+      submitButton: false,
+      allGoods: [],
+      multipleSelection: [],
+      goodsNums: [],
+      numList: [],
+      sell_price_sum: 0.00,
+      price_pv_sum: 0.00,
+      payList: [],
+      sn: '',
+      payDialog: false,
+      countdown: 5,
+      visible: false,
+      payStackLoading: false,
+      channels: ['card', 'bank', 'ussd', 'qr'], // eft(南非)  mobile_money(加纳)
+      PayStackForm: {
+        publicKey: PAY_STACK_PUBLIC_KEY,
+        currency: PAY_STACK_CURRENCY,
+        firstname: userInfo.userName(),
+        lastname: '',
+        email: userInfo.userEmail(),
+        amount: 0, // kobo
+        orderSn: '',
+        metadata: {
+          cart_id: this.sn,
+          custom_fields: [
+            {
+              display_name: 'orderSn',
+              variable_name: 'orderSn',
+              value: this.sn
             },
-            handleSelectionChange(val) {
-                let idx = -1,num;
-                for(let i in this.tableDatas){
-                    for(let v in val){
-                        if(val[v].ID==this.tableDatas[i].ID){
-                            idx = i;
-                            num = this.numList[idx];
-                            val[v]["goodsNum"] = num;
-                            break;
-                        }
-                    }
-                }
-                console.log(val)
-                this.multipleSelection = val;
+          ]
+        },
+      },
+    }
+  },
+  components: {
+    paystack
+  },
+  methods: {
+    // 获取要升级的会员信息
+    upgradeInfo () {
+      if (this.form.insertUserName) {
+        network.postData(`user/upgrade-info`,{userName:this.form.insertUserName}).then(response => {
+          this.form.addAt=response.baseInfo.ADD_AT
+          this.form.userRealName=response.baseInfo.REAL_NAME
+          this.form.userDecName=response.baseInfo.DEC_NAME
+          this.isMax = response.baseInfo.IS_MAX
+          this.upgradeOption = response.baseInfo.LEVEL_LIST
+          this.form.upgradeFunc = response.baseInfo.UPGRADE_FUNC //upgradeFunc升级方式
+          this.nowPerf = response.baseInfo.NOW_PERF // 用户当前业绩
+          this.nextPerf = response.baseInfo.NEXT_PERF
+        })
+      }
+    },
+    changeLevel (data) {
+      let { value,diffPv } = data
+      this.needDiffPv = diffPv
+      this.toLevel = value
+    },
+    getSum () {
+      let sell_price_sum=0, price_pv_sum=0;
+      this.multipleSelection.map((item,index) => {
+        sell_price_sum += Number(item.SELL_PRICE) * item.goodsNum;
+        price_pv_sum += Number(item.PRICE_PV) * item.goodsNum;
+      })
+      this.sell_price_sum = tool.formatPrice(sell_price_sum);
+      this.price_pv_sum = tool.formatPrice(price_pv_sum);
+    },
+    getData () {
+      network.getData(`user/upgrade`).then(response => {
+        this.decUserName = response.decUserName
+        this.loading = false;
+        this.allDecPackage = response.allDecPackage;
+        this.allGoods = response.allGoods;
+        let settingObj = this.allDecPackage;
+        let settingArr = Object.keys(settingObj).map(key => {
+          // console.log(key); //为每个键名
+          return settingObj[key];  // 把每个对象返回出去生成一个新的数组中相当于0:{id:1}
+        });
+        this.tableData = settingArr;
+        let settingObj1 = this.allGoods;
+        for (let i in settingObj1) {
+          this.numList[i] = 1;
+          settingObj1[i].goodsNum= 1 ;
+        }
+        this.tableDatas=settingObj1;
 
-            },
-            handleChange(value,ID) {
-                for(let i in this.multipleSelection){
-                    if(this.multipleSelection[i]['ID']==ID) {
-                        this.multipleSelection[i]["goodsNum"] = value;
-                    }
-                }
-            },
-            getGoods(){
-                this.form.goodsId=[];
-                this.form.goodsNum=[];
-                this.multipleSelection.map((item,index)=>{
-                    console.log(item);
-                    console.log('==');
-                    this.form.goodsId.push(item.ID)
-                    this.form.goodsNum.push(item.goodsNum)
-            })
-            },
-            onSubmit() {
-                if (!this.form.insertUserName) {
-                    this.$message({
-                        message: 'Please enter the member code',//请输入会员编号
-                        type: 'error'
-                    })
-                    return false;
-                }
-                if (!this.toLevel) {
-                    this.$message({
-                        message: 'Please select a level',//请选择级别
-                        type: 'error'
-                    })
-                    return false
-                }
+        // 支付方式
+        this.payList = response.sellType[0]['sell_type']
+        // 支付方式的第一项默认选中
+        this.form.payType = Object.values(this.payList)[1]['label']
+      }).catch(() => {
+      });
+    },
+    handleCurrentChange (val) {
+      console.log(val)
+      if (!val) { return }
+      this.currentRow = val;
+      this.form.packageId = this.currentRow.ID;
 
-                this.getGoods();
-                this.submitButtonStat = true
-                let path = 'user/upgrade'
-                let postData = {
-                    decUserName:this.decUserName,
-                    packageId: this.form.packageId,
-                    goodsId: this.form.goodsId,
-                    goodsNum: this.form.goodsNum,
-                    location: this.form.location,
-                    decWay:this.decWay,
-                    decLv:this.toLevel, // 用户想升级到什么级别
-                    insertUserName:this.form.insertUserName, // 要升级的用户的编号
-                    remark:this.form.remark,
-                    address: this.form.address,
-                    consignee: this.form.consignee,
-                    acceptMobile: this.form.acceptMobile,
-                    province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
-                    // city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
-                    // county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
-                    lgaName: this.form.lgaName,
-                    cityName: this.form.cityName,
-                    nowPerf:this.nowPerf,
-                    nextPerf:this.nextPerf,
-                    payType: this.form.payType,
-                }
+      console.log(this.form.packageId)
+    },
+    handleSelectionChange (val) {
+      let idx = -1, num;
+      for (let i in this.tableDatas) {
+        for (let v in val) {
+          if (val[v].ID === this.tableDatas[i].ID) {
+            idx = i;
+            num = this.numList[idx];
+            val[v]['goodsNum'] = num;
+            break;
+          }
+        }
+      }
+      console.log(val)
+      this.multipleSelection = val;
 
-                return network.postData(path, postData).then(response => {
-                    // 非PayStack支付
-                    if (this.form.payType !== 'pay_stack') {
-                        this.$message({
-                          message: response,
-                          type: 'success'
-                        })
-                        this.submitButtonStat = false
-                        this.$router.push({path: `/shop/order-list`})
-                    } else {
-                        // PayStack支付
-                        this.submitButtonStat = false
-                        this.PayStackForm.orderSn = response.SN
-                        this.PayStackForm.amount = response.ORDER_AMOUNT
-                        this.PayStackForm.metadata.custom_fields[0].value = response.SN
-                        this.visible = true
-                    }
-                }).catch(() => {
-                    this.submitButtonStat = false
-                })
-            },
+    },
+    handleChange (value,ID) {
+      for (let i in this.multipleSelection) {
+        if (this.multipleSelection[i]['ID'] === ID) {
+          this.multipleSelection[i]['goodsNum'] = value;
+        }
+      }
+    },
+    getGoods () {
+      this.form.goodsId = [];
+      this.form.goodsNum = [];
+      this.multipleSelection.map((item,index) => {
+        console.log(item);
+        console.log('==');
+        this.form.goodsId.push(item.ID)
+        this.form.goodsNum.push(item.goodsNum)
+      })
+    },
+    onSubmit () {
+      if (!this.form.insertUserName) {
+        this.$message({
+          message: 'Please enter the member code',//请输入会员编号
+          type: 'error'
+        })
+        return false;
+      }
+      if (!this.toLevel) {
+        this.$message({
+          message: 'Please select a level',//请选择级别
+          type: 'error'
+        })
+        return false
+      }
 
-            selectOne(event, item) {
-                network.getData(`user/upgrade`).then(response => {
+      this.getGoods();
+      this.submitButtonStat = true
+      let path = 'user/upgrade'
+      let postData = {
+        decUserName: this.decUserName,
+        packageId: this.form.packageId,
+        goodsId: this.form.goodsId,
+        goodsNum: this.form.goodsNum,
+        location: this.form.location,
+        decWay: this.decWay,
+        decLv: this.toLevel, // 用户想升级到什么级别
+        insertUserName: this.form.insertUserName, // 要升级的用户的编号
+        remark: this.form.remark,
+        address: this.form.address,
+        consignee: this.form.consignee,
+        acceptMobile: this.form.acceptMobile,
+        province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
+        // city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
+        // county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
+        lgaName: this.form.lgaName,
+        cityName: this.form.cityName,
+        nowPerf: this.nowPerf,
+        nextPerf: this.nextPerf,
+        payType: this.form.payType,
+      }
 
-                })
+      return network.postData(path, postData).then(response => {
+        // 非PayStack支付
+        if (this.form.payType !== 'pay_stack') {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.submitButtonStat = false
+          this.$router.push({path: `/shop/order-list`})
+        } else {
+          // PayStack支付
+          this.submitButtonStat = false
+          this.PayStackForm.orderSn = response.SN
+          this.PayStackForm.amount = response.ORDER_AMOUNT
+          this.PayStackForm.metadata.custom_fields[0].value = response.SN
+          this.visible = true
+        }
+      }).catch(() => {
+        this.submitButtonStat = false
+      })
+    },
 
-            },
+    selectOne (event, item) {
+      network.getData(`user/upgrade`).then(response => {
+      })
+    },
 
-            handleChkConUser() {
-                if (this.form.conUserName) {
-                    this.loading = true
-                    network.getData('user/full-info', {userName: this.form.conUserName}).then(response => {
-                        this.conRealName = response.REAL_NAME + response.isLocation
-                        this.loading = false
-                    }).catch(response => {
-                        this.conRealName = '-'
-                        this.loading = false
-                    })
-                }
-            },
+    handleChkConUser () {
+      if (this.form.conUserName) {
+        this.loading = true
+        network.getData('user/full-info', {userName: this.form.conUserName}).then(response => {
+          this.conRealName = response.REAL_NAME + response.isLocation
+          this.loading = false
+        }).catch(response => {
+          this.conRealName = '-'
+          this.loading = false
+        })
+      }
+    },
 
-            handleChkRecUser() {
-                if (this.form.recUserName) {
-                    this.loading = true
-                    network.getData('user/full-info', {userName: this.form.recUserName}).then(response => {
-                        this.recRealName = response.REAL_NAME
-                        this.loading = false
-                    }).catch(response => {
-                        this.recRealName = '-'
-                        this.loading = false
-                    })
-                }
-            },
-            // 切换支付方式
-            payMethodChange(type) {
-                this.form.payType = type
-            },
-            // 关闭支付回调
-            handleClose() {
-                let _this = this
-                _this.$confirm('Confirm to close?').then(() => {
-                    return network.postData('shop/delete-approach-order', {orderSn: this.PayStackForm.orderSn}).then(() => {
-                        // 关闭支付模态框
-                        _this.visible = false
-                    })
-                }).catch(() => {
-                    // 关闭支付模态框
-                    _this.visible = false
-                })
-            },
-            // 支付成功回调
-            processPayment(response) {
-                // 关闭支付页面
-                this.visible = false
-                this.payStackLoading = false
+    handleChkRecUser () {
+      if (this.form.recUserName) {
+        this.loading = true
+        network.getData('user/full-info', {userName: this.form.recUserName}).then(response => {
+          this.recRealName = response.REAL_NAME
+          this.loading = false
+        }).catch(response => {
+          this.recRealName = '-'
+          this.loading = false
+        })
+      }
+    },
+    // 切换支付方式
+    payMethodChange (type) {
+      this.form.payType = type
+    },
+    // 关闭支付回调
+    handleClose () {
+      let _this = this
+      _this.$confirm('Confirm to close?').then(() => {
+        return network.postData('shop/delete-approach-order', {orderSn: this.PayStackForm.orderSn}).then(() => {
+          // 关闭支付模态框
+          _this.visible = false
+        })
+      }).catch(() => {
+        // 关闭支付模态框
+        _this.visible = false
+      })
+    },
+    // 支付成功回调
+    processPayment (response) {
+      // 关闭支付页面
+      this.visible = false
+      this.payStackLoading = false
 
-                // 显示支付成功模态框
-                this.payDialog = true
-                this.handleCountdown()
-            },
-            // 关闭支付回调
-            processClose() {
-                // 关闭支付模态框
-                this.visible = false
-            },
-            // 支付tips结束,跳转到报单列表
-            handleOrderList() {
-                this.$router.push({path: `/shop/dec-order-list`})
-            },
-            // 启动倒计时
-            handleCountdown() {
-                //创建定时器
-                setInterval(() => {
-                    // 每隔1秒把time的值减一,赋值给span标签
-                    this.countdown--
-                    if (this.countdown === 0) {
-                        // 倒计时结束,跳转到报单列表
-                        this.$router.push({path: `/shop/dec-order-list`})
-                    }
-                }, 1000)
-            },
+      // 显示支付成功模态框
+      this.payDialog = true
+      this.handleCountdown()
+    },
+    // 关闭支付回调
+    processClose () {
+      // 关闭支付模态框
+      this.visible = false
+    },
+    // 支付tips结束,跳转到报单列表
+    handleOrderList () {
+      this.$router.push({path: `/shop/dec-order-list`})
+    },
+    // 启动倒计时
+    handleCountdown () {
+      // 创建定时器
+      setInterval(() => {
+        // 每隔1秒把time的值减一,赋值给span标签
+        this.countdown--
+        if (this.countdown === 0) {
+          // 倒计时结束,跳转到报单列表
+          this.$router.push({path: `/shop/dec-order-list`})
         }
-    }
+      }, 1000)
+    },
+  }
+}
 </script>
 
 <style>