first commit
This commit is contained in:
123
衣莎项目/源码/YiShaXiYi/pages/choice/choice.js
Normal file
123
衣莎项目/源码/YiShaXiYi/pages/choice/choice.js
Normal file
@@ -0,0 +1,123 @@
|
||||
// user/choice/choice.js
|
||||
const app = getApp();
|
||||
const regeneratorRuntime = app.loadAsync()
|
||||
const model = app.loadModel("index")
|
||||
const util = app.loadUtils("util")
|
||||
const http = app.loadHttp()
|
||||
const api = app.loadApi()
|
||||
Component({
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
properties: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
system: app.globalData.system, //设备相关信息
|
||||
pageTitle: "伊莎洗衣", //头部标题
|
||||
isLocation: true, //是否显示定位
|
||||
titleColor: { //头部背景和文字颜色
|
||||
bColor: "#1dbf53",
|
||||
tColor: "#ffffff"
|
||||
},
|
||||
cityInfo: {
|
||||
city: "定位中",
|
||||
location: ""
|
||||
},//最新门店
|
||||
imgObj: {},
|
||||
isPopup: false, //弹出层显示
|
||||
branchList: [],
|
||||
branchIndex: -1,// 当前用户选择的支行下标
|
||||
},
|
||||
ready() {
|
||||
this.add()
|
||||
this.groupBranchList()
|
||||
if(app.globalData.userInfo.group_branch == 0){
|
||||
this.setData({
|
||||
isPopup: true
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
async tuanPic(group_type) {
|
||||
let res = await http.http.request2({ url: http.api.tuanPic, method: 'POST', data: { group_type: group_type } })
|
||||
this.setData({
|
||||
imgObj: res.data.data
|
||||
})
|
||||
},
|
||||
// 授权和获取用户当前经纬度,并展示最近门店
|
||||
async add() {
|
||||
// 判断本地是否有最近门店,只在第一次进小程序请求后端获取最近门店
|
||||
let storageAdd = await model.storage.getSetting("nearestStore")
|
||||
let cityInfo = {}
|
||||
if (!!storageAdd) {
|
||||
cityInfo = {
|
||||
city: storageAdd.name.substring(0, 4),
|
||||
location: "/pages/nearbyStore/nearbyStore"
|
||||
}
|
||||
this.setData({
|
||||
cityInfo: cityInfo
|
||||
})
|
||||
return
|
||||
}
|
||||
let res = await model.getauth.userLocation()
|
||||
cityInfo = {
|
||||
city: res.name.substring(0, 4),
|
||||
location: "/pages/nearbyStore/nearbyStore"
|
||||
}
|
||||
this.setData({
|
||||
cityInfo: cityInfo
|
||||
})
|
||||
},
|
||||
// 跳转
|
||||
async goDiamondInfo(e) {
|
||||
let url = e.currentTarget.dataset.url
|
||||
let isLogin = await util.isLoginJump()
|
||||
if (isLogin == 1) return;
|
||||
// 洗衣价目表
|
||||
wx.navigateTo({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
// 获取支行列表
|
||||
async groupBranchList() {
|
||||
let res = await http.http.request2({ url: http.api.groupBranchList, method: 'POST' })
|
||||
this.setData({
|
||||
branchList: res.data.data
|
||||
})
|
||||
},
|
||||
pickerChange(e) {
|
||||
this.setData({
|
||||
branchIndex: parseInt(e.detail.value)
|
||||
})
|
||||
},
|
||||
async bindBranch() {
|
||||
if(this.data.branchIndex == -1){
|
||||
wx.showToast({
|
||||
title: '请选择分行',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
return
|
||||
}
|
||||
let res = await http.http.request2({ url: http.api.bindBranch, method: 'POST', data:{branch_id:this.data.branchList[this.data.branchIndex].id} })
|
||||
if(res.data.status == 1){
|
||||
wx.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
this.setData({
|
||||
isPopup: false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user