微信小程序实用demo:省市县三级联动

这是一款来自小程序免费开发制作网的小程序demo源码,希望大家喜欢。 

001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 var config = require(‘../../utils/config.js’) var mta = require(‘../../utils/mta_analysis.js’) var utils=require(‘../../utils/util’) var dataC; // 保存所有城市列表   var allCity; // 保存所有城市列表 var currentProvince; // 滚轮当前指向的省 var currentCity; var currentArea; var enterProvince; // 按下确定键后,保存到这里,用于发送请求 var enterCity; var enterArea;       var remoteAvatar = ”; // 头像路径 var remoteVideo = ”; var remotePics = [];   Page({     data: {         shopName: ”,         shopPhone: ”,         shopAddress: ”,         pics: [],         showOrHide: ‘show’,         locationStr:”请选择您的城市”,         shopIntroduce:””,         nian:”,         yue:”,         ri:”     },     onLoad: function (options) {         var that = this;         var dataC=utils.getData();         console.log(dataC.p[0]);         currentProvince = dataC.p[0];         console.log(currentProvince);     },     onReady: function () {         mta.rptMain();     },     showCityPicker: function () {         if (!currentProvince) {             currentProvince = dataC.p[0];             console.log(currentProvince);             currentCity = dataC.c[currentProvince][0];             currentArea = dataC.a[currentCity][0];         }         this.setData({             showOrHide: ‘show’,             provinces: dataC.p,             citys: dataC.c[currentProvince],             areas: dataC.a[currentCity]         })     },     scrollProvince: function (e) {         var dY = e.detail.scrollTop;         var a = Math.round(dY / 20); // 移动的整位         currentProvince = dataC.p[a]; // 选中的省         currentCity = dataC.c[currentProvince][0] // 选中的城市         currentArea = dataC.a[currentCity][0]; // 选中的区         this.setData({             citys: dataC.c[currentProvince],             areas: dataC.a[currentCity]         })     },     scrollCity: function (e) {         var dY = e.detail.scrollTop;         var a = Math.round(dY / 20); // 移动的整位         currentCity = dataC.c[currentProvince][a] // 选中的城市         currentArea = dataC.a[currentCity][0]; // 选中的区         this.setData({             areas: dataC.a[currentCity]         })     },     scrollArea: function (e) {         var dY = e.detail.scrollTop;         var a = Math.round(dY / 20); // 移动的整位         currentArea = dataC.a[currentCity][a]; // 选中的区     },     cancelPick: function () {         this.setData({             showOrHide: ‘hide’         })     },     enterPick: function () {         enterProvince = currentProvince;         enterCity = currentCity;         enterArea = currentArea;         this.setData({             showOrHide: ‘hide’,             locationStr: enterProvince + ”  ” + enterCity + ”  ” + enterArea         })     },     formSubmit: function (e) {         var that = this;         // 检查所有参数是否完整         if (!this.data.avatarSrc) {             wx.showToast({                 title: ‘头像不能为空’,                 duration: 2000             })         }         if (!e.detail.value.shopName) {             wx.showToast({                 title: ‘商铺名称不能为空’,                 duration: 2000             })         }         if (!e.detail.value.sellerPhone) {             wx.showToast({                 title: ‘手机号不能为空’,                 duration: 2000             })         }         if (!this.data.locationStr || !e.detail.value.shopAddress) {             wx.showToast({                 title: ‘商铺地址不能为空’,                 duration: 2000             })         }         if (!e.detail.value.introduction) {             wx.showToast({                 title: ‘介绍不能为空’,                 duration: 2000             })         }         if (this.data.pics.length < 3) {             wx.showToast({                 title: ‘繁育环境照片最少3张’,                 duration: 2000             })         }     }, })

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 var utils = require(‘../../utils/util’); const p = [];//省 const a = [];//市 const c = [];//区,县 var riqi;//日期 var val;//下标 Page({     data: {         boxHide:”box-show”,         showBox:”hide-show”     },     onLoad: function (options) {         var dataC = utils.getData();         p.push(dataC.p);//province         a.push(dataC.a);//area         c.push(dataC.c);//city     },     bindChange: function (e) {         val = e.detail.value;         riqi = this.data;         this.setData({             months: c[0][riqi.years[val[0]]],             days: a[0][riqi.months[val[1]]]         })     },     yes: function () {//获取城市信息         if (typeof (riqi) == “undefined”) {             this.setData({                 nian: “黑龙江省”,                 yue: “大兴安岭地区”,                 ri: “塔河县”             })         } else {             this.setData({                 nian: this.data.years[val[0]],                 yue: this.data.months[val[1]],                 ri: this.data.days[val[2]]             })         }     },     cancelPick: function () {         this.setData({             boxHide:”box-show”,             showBox:”hide-show”         })     },     enterPick: function () {         console.log(c[0][p[0][0]][0]);         this.setData({             boxHide:”box-hide”,             showBox:”show-box”,             years: p[0],             months: c[0][p[0][0]],             days: a[0][c[0][p[0][0]][0]]         })     },     enter: function () {         if (typeof (riqi) == “undefined”) {             this.setData({                 nian: “黑龙江省”,                 yue: “大兴安岭地区”,                 ri: “塔河县”             })         } else {             this.setData({                 nian: this.data.years[val[0]],                 yue: this.data.months[val[1]],                 ri: this.data.days[val[2]]             })         }     } });  

免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。

本资源来自易用通,如有侵权,请联系站长。

【小程序源码网资源版权风险说明】:
本站为避免不必要的纷争,分享的所有资源中一切可能有版权风险的资源将全部转载自第三方网站或平台,站长只为大家提供相关资源的介绍和跳转引导。 因可能有疏忽大意,所以如有遗漏资源侵犯了您的合法权利,请联系站长删除。
【小程序源码网资源下载使用说明】:
本站所分享的一切QQ小程序源码,thinkphp整站源码,微信小程序源码,图文教程等资源仅供用户学习参考使用,任何人不得作其他用途,违者自行承担所有责任。
【小程序源码网毫无人看的介绍】:
本站又称Z站,原名贼娘网,开站于2018年,换过三任站长,目前站长是第四任站长,本站是一个主要分享免费开源小程序源码/网站源码/免费素材/教程资源的网站,主要小程序资源有用于学习的小程序源码,也有正版原创可商用的小程序源码,是一个公益博客型网站。
【小程序源码网原创源码版权申明】:
未经小程序源码网许可,任何人不得擅自使用本站原创首发源码进行商业行为(除本站VIP用户在期限内,版权无使用限制),否则将依法承担相应赔偿责任。
【小程序源码网转载文章版权申明】:
本站所转载的QQ小程序或微信小程序源码与其他资源仅供学习,任何人不得作其他用途,违者自行承担所有责任。
【小程序源码网站长最后的屁话】:
如有您认为本站有任何侵犯您合法权益的文章,或者您有什么疑问需求,欢迎联系站长QQ,站长24小时在线,备注公司名称和源码版权问题或者需要小程序定制开发等站长业务类型可急速处理,如果您只是交流小程序的一些开发问题或源码问题可以加入QQ群讨论,就不用加站长啦,对于白嫖党,QQ群才是处理问题的天堂,当然站长也欢迎大家骚扰~
小程序源码网 » 微信小程序实用demo:省市县三级联动
嘿,投喂下嘛!