From a75b18a4157ab486e0b51c438ac165ab3a08e3e0 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 18:10:00 +0800
Subject: [PATCH] 代码提交
---
wechat_jiaxuan/pages/design/design.js | 150 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 135 insertions(+), 15 deletions(-)
diff --git a/wechat_jiaxuan/pages/design/design.js b/wechat_jiaxuan/pages/design/design.js
index 45c24b2..6c9fcf1 100644
--- a/wechat_jiaxuan/pages/design/design.js
+++ b/wechat_jiaxuan/pages/design/design.js
@@ -1,4 +1,10 @@
-// pages/design/design.js
+import {
+ getDictData,
+ getArea,
+ saveFreeCustomizationApply
+} from '../../api/index'
+var QQMapWX = require('../../utils/qqmap-wx-jssdk.min');
+var qqmapsdk;
Page({
/**
@@ -7,26 +13,140 @@
data: {
name: '',
phone: '',
- city: ''
+
+ showAreaList: false,
+ areaList: [],
+ addr: {},
+ fieldNames: {
+ text: 'name',
+ value: 'id',
+ children: 'children',
+ },
+ cascaderValue: '',
+
+ DESIGN_BANNER: '',
+ WechatIMG558: '',
},
onLoad(options) {
-
+ this.initData()
+ qqmapsdk = new QQMapWX({
+ key: 'HIDBZ-2QXL4-TAWUD-XET6Q-EKTJE-CCBSQ'
+ });
+ qqmapsdk.reverseGeocoder({
+ success: (res) => {
+ console.log('res', res);
+ let addr = {
+ // provinceCode: codes[0] + '00',
+ provinceName: res.result.ad_info.province,
+ // cityCode: codes[1] + '00',
+ cityName: res.result.ad_info.city,
+ // areaCode: codes[2] + '00',
+ areaName: res.result.ad_info.district,
+ }
+ this.setData({ addr })
+ }
+ })
},
onSubmit() {
- console.log('dd', this.data.name);
- console.log('dd', this.data.phone);
+ 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'
+ })
+ saveFreeCustomizationApply({
+ name,
+ phone,
+ ...addr
+ }).then(res => {
+ wx.showToast({
+ title: '鎶ュ悕鎴愬姛'
+ })
+ wx.switchTab({
+ url: '/pages/index/index',
+ })
+ })
},
- selAddress() {
- console.log('鐐瑰嚮浜�');
- wx.chooseLocation({
- type: 'wgs84',
- success: (res)=> {
- this.setData({
- city: res.name
- })
- console.log('res', res);
- }
+ // 鏄剧ず鍩庡競寮圭獥
+ chooseCity () {
+ this.setData({ showAreaList: !this.data.showAreaList })
+ console.log('chooseCity', this.data.showAreaList);
+ },
+ 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)
+ 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 })
+ },
+ initData() {
+ getArea({
+ "level": "",
+ "pid": ""
+ }).then(res => {
+ this.setData({areaList: res.data})
+ })
+ 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