123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //index.js
- //获取应用实例
- const app = getApp()
- Page({
- data: {
- form: {},
- // 省份
- provinceList: [],
- // 市区
- cityList: [],
- // 套餐列表
- setList: [],
- },
- // 选择省份
- provinceChange: function (e) {
- this.setData({ "form.province": this.data.provinceList[e.detail.value].code })
- // 查询市
- wx.request({
- url: app.globalData.publicUrl + '/api/htyd/xzqh',
- method: "get",
- data: { pcode: this.data.provinceList[e.detail.value].code },
- success: (res) => {
- if (res.data.errcode == '0') {
- this.setData({ cityList: res.data.data })
- // 根据查询市,判断查询套餐
- if (res.data.total === 0) {
- // 套餐
- wx.request({
- url: app.globalData.publicUrl + '/api/htyd/set',
- method: "get",
- data: { contact: this.data.provinceList[e.detail.value].code },
- success: (res) => {
- if (res.data.errcode == '0') {
- this.setData({ setList: res.data.data })
- } else {
- wx.showToast({
- title: '查询失败',
- icon: 'error',
- duration: 2000
- })
- }
- }
- })
- }
- } else {
- wx.showToast({
- title: '查询失败',
- icon: 'error',
- duration: 2000
- })
- }
- }
- })
- },
- // 选择市区
- cityChange: function (e) {
- this.setData({ "form.city": this.data.cityList[e.detail.value].code })
- // 套餐
- wx.request({
- url: app.globalData.publicUrl + '/api/htyd/set',
- method: "get",
- data: { contact: this.data.cityList[e.detail.value].code },
- success: (res) => {
- if (res.data.errcode == '0') {
- this.setData({ setList: res.data.data })
- } else {
- wx.showToast({
- title: '查询失败',
- icon: 'error',
- duration: 2000
- })
- }
- }
- })
- },
- // 选择套餐
- setChange: function (e) {
- this.setData({ "form.set": this.data.setList[e.detail.value].id })
- },
- //事件处理函数
- formSubmit: function (e) {
- const params = e.detail.value;
- wx.request({
- url: app.globalData.publicUrl + '/api/htyd/card',
- method: "post",
- data: params,
- success: (res) => {
- if (res.data.errcode == '0') {
- wx.showToast({
- title: '办卡成功',
- icon: 'success',
- duration: 2000
- })
- } else {
- wx.showToast({
- title: '办卡失败',
- icon: 'error',
- duration: 2000
- })
- }
- }
- })
- },
- onLoad: function () {
- // 获取推荐人信息
- let data = app.globalData.userInfo;
- if (data) {
- this.setData({ "form.recommend": data.name })
- this.setData({ "form.r_mobile": data.mobile })
- }
- // 查询省
- wx.request({
- url: app.globalData.publicUrl + '/api/htyd/xzqh',
- method: "get",
- data: {},
- success: (res) => {
- if (res.data.errcode == '0') {
- this.setData({ provinceList: res.data.data })
- } else {
- wx.showToast({
- title: '查询失败',
- icon: 'error',
- duration: 2000
- })
- }
- }
- })
- },
- })
|