From 7dc29ed74ebaa8a0e66f68264d9a13f95dc3af21 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 02 八月 2024 11:09:06 +0800
Subject: [PATCH] aa

---
 wechat_jiaxuan/pages/design/design.js |  185 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 167 insertions(+), 18 deletions(-)

diff --git a/wechat_jiaxuan/pages/design/design.js b/wechat_jiaxuan/pages/design/design.js
index 45c24b2..ce18bfd 100644
--- a/wechat_jiaxuan/pages/design/design.js
+++ b/wechat_jiaxuan/pages/design/design.js
@@ -1,4 +1,11 @@
-// pages/design/design.js
+// import { areaList } from '@vant/area-data';
+import {
+  getDictData,
+  getArea,
+  saveFreeCustomizationApply
+} from '../../api/index'
+var QQMapWX = require('../../utils/qqmap-wx-jssdk.min');
+var qqmapsdk;
 Page({
 
   /**
@@ -6,28 +13,170 @@
    */
   data: {
     name: '',
-    phone: '',
-    city: ''
+    phone: '',  
+    showAreaList: false,
+    areaList: [],
+    addr: {},
+    addrValues:[],
+    fieldNames: {
+      text: 'name',
+      value: 'id',
+      children: 'children',
+    },
+    cascaderValue: '',
+
+    DESIGN_BANNER: '',
+    WechatIMG558: '',
   },
   onLoad(options) {
-
-  },
-
-  onSubmit() {
-    console.log('dd', this.data.name);
-    console.log('dd', this.data.phone);
-  },
-  selAddress() {
-    console.log('鐐瑰嚮浜�');
-    wx.chooseLocation({
-      type: 'wgs84',
-      success: (res)=> {
-        this.setData({
-          city: res.name
-        })
+    this.initData()
+    qqmapsdk = new QQMapWX({
+      key: 'HIDBZ-2QXL4-TAWUD-XET6Q-EKTJE-CCBSQ'
+    });
+    qqmapsdk.reverseGeocoder({
+      success: (res) => {
         console.log('res', res);
+        let addr = {
+          provinceCode: res.result.ad_info.adcode.slice(0,2) + '000000',
+          provinceName: res.result.ad_info.province,
+          cityCode: res.result.ad_info.adcode.slice(0,4) + '0000',
+          cityName: res.result.ad_info.city,
+          areaCode: res.result.ad_info.adcode + '00',
+          areaName: res.result.ad_info.district,
+        }
+        this.setData({ addr,addrValues:
+          [res.result.ad_info.adcode.slice(0,2) + '0000',
+          res.result.ad_info.adcode.slice(0,4) + '00',
+          res.result.ad_info.adcode]  })    
       }
     })
+    const member =  wx.getStorageSync('member')
+    this.setData({
+      phone: member.phone,
+      name: member.name
+    })
+  }, 
+  regionChange(e) {
+    console.log(e) 
+    if(e.detail.value &&e.detail.value.length ==3){
+      var tn = e.detail.label.split("-")
+      const addr = {
+        provinceCode: e.detail.value[0] ,
+        provinceName: tn[0],
+        cityCode:  e.detail.value[1] ,
+        cityName:  tn[1],
+        areaCode: e.detail.value[2] ,
+        areaName:  tn[2]
+      }
+      this.setData({ addr, showAreaList: false })
+      console.log('selectedOptions', addr);
+    } 
+  },
+  onSubmit() {
+    const {
+      name,
+      phone,
+      addr
+    } = this.data
+    if (!name) return wx.showToast({
+      title: '璇疯緭鍏ュ鍚�',
+      icon: 'none'
+    })
+    if (!phone) return wx.showToast({
+      title: '璇疯緭鍏ヨ仈绯荤數璇�',
+      icon: 'none'
+    })
+    if (phone.length !== 11) return wx.showToast({
+      title: '璇疯緭鍏ユ纭殑鑱旂郴鐢佃瘽',
+      icon: 'none'
+    })
+    if (!addr.areaCode || !addr.cityCode) return wx.showToast({
+      title: '璇烽�夋嫨鍩庡競',
+      icon: 'none'
+    })
+    console.log({
+      name,
+      phone,
+      ...addr
+    })
+    saveFreeCustomizationApply({
+      name,
+      phone,
+      ...addr
+    }).then(res => {
+      wx.showToast({
+        title: '鎶ュ悕鎴愬姛'
+      })
+      setTimeout(() => {
+        wx.navigateBack()
+      }, 1000)
+    })
+  },
+  onFinish(e) {
+    const { selectedOptions, value } = e.detail;
+    const addr = {
+      provinceCode: selectedOptions[0].id,
+      provinceName: selectedOptions[0].name,
+      cityCode: selectedOptions[1].id,
+      cityName: selectedOptions[1].name,
+      areaCode: selectedOptions[2].id,
+      areaName: selectedOptions[2].name,
+    }
+    this.setData({ addr, showAreaList: false })
+    console.log('selectedOptions', addr);
+  },
+  positionChange (e) {
+    console.log(e.detail.value)
+    console.log(e.detail.code)
+    const names = e.detail.value
+    const codes = e.detail.code
+    let addr = {
+      provinceCode: codes[0] + '00',
+      provinceName: names[0],
+      cityCode: codes[1] + '00',
+      cityName: names[1],
+      areaCode: codes[2] + '00',
+      areaName: names[2],
+    }
+    this.setData({ addr })
+  },
+  bindRegionChange(e) {
+    console.log('picker鍙戦�侀�夋嫨鏀瑰彉锛屾惡甯﹀�间负', e.detail.value)
+    const temp = e.detail.value
+    this.setData({
+      region: e.detail.value
+    })
+  },
+  onClose() {
+    this.setData({ showAreaList: false })
+  },
+  onClick() {
+    this.setData({ showAreaList: true })
+  },
+  initData() {
+    // getArea({
+    //   "level": "",
+    //   "pid": ""
+    // }).then(res => {  
+    //   this.setData({areaList: res.data})
+    //   console.log(this.data.areaList)
+    // })
+    getDictData({
+      code: 'WEIXIN_DEFAULT_IMGS',
+      label: 'DESIGN_BANNER'
+    }).then(res => {
+      this.setData({
+        DESIGN_BANNER: res.data.code
+      })
+    })
+    getDictData({
+      code: 'WEIXIN_DEFAULT_IMGS',
+      label: 'WechatIMG558'
+    }).then(res => {
+      this.setData({
+        WechatIMG558: res.data.code
+      })
+    })
   },
   onReady() {
 

--
Gitblit v1.9.3