开始做充值和发票
This commit is contained in:
138
pages/handleLogin/index.js
Normal file
138
pages/handleLogin/index.js
Normal file
@@ -0,0 +1,138 @@
|
||||
import { userValidate } from "../../service/user";
|
||||
import { alertInfo, alertSuccess, loadingFunc, wxLogin } from "../../utils/index";
|
||||
import request from "../../utils/request"
|
||||
const { OK } = request;
|
||||
// pages/handleLogin/index.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
phone: "",
|
||||
name: "",
|
||||
parkName: "",
|
||||
park: "",
|
||||
tenementName: "",
|
||||
tenement: ""
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
onChangeName(e) {
|
||||
this.setData({
|
||||
name: e.detail
|
||||
})
|
||||
},
|
||||
onChangePhone(e) {
|
||||
this.setData({
|
||||
phone: e.detail
|
||||
})
|
||||
},
|
||||
onChoosePark(e) {
|
||||
const { data } = e.detail;
|
||||
this.setData({
|
||||
park: data.id,
|
||||
parkName: data.name
|
||||
})
|
||||
},
|
||||
onChooseTenement(e) {
|
||||
const { data } = e.detail;
|
||||
this.setData({
|
||||
tenement: data.id,
|
||||
tenementName: data.name
|
||||
})
|
||||
},
|
||||
handleSubmit() {
|
||||
const { park, tenement, name, phone } = this.data;
|
||||
if (!park) {
|
||||
alertInfo("请选择园区")
|
||||
return
|
||||
}
|
||||
if (!tenement) {
|
||||
alertInfo("请选择商户")
|
||||
return
|
||||
}
|
||||
if (!phone) {
|
||||
alertInfo("请输入联系人手机号")
|
||||
return
|
||||
}
|
||||
if (!name) {
|
||||
alertInfo("请输入你的昵称")
|
||||
return
|
||||
}
|
||||
loadingFunc(async () => {
|
||||
const wxLoginCode = await wxLogin()
|
||||
const { code, message, data } = await userValidate({ park, tenement, phone, name, code: wxLoginCode })
|
||||
// if (code !== OK) {
|
||||
// alertInfo(message)
|
||||
// return
|
||||
// }
|
||||
const { exist, user } = data;
|
||||
if (!exist) {
|
||||
alertInfo("绑定失败,请检查信息")
|
||||
return
|
||||
}
|
||||
alertSuccess("绑定成功")
|
||||
const { token, ...currentUser } = user;
|
||||
wx.setStorageSync('user', currentUser)
|
||||
wx.setStorageSync('token', token)
|
||||
wx.switchTab({
|
||||
url: '/pages/home/index',
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
9
pages/handleLogin/index.json
Normal file
9
pages/handleLogin/index.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"topbar": "/components/topbar/index",
|
||||
"select": "/components/select/index",
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-field": "@vant/weapp/field/index"
|
||||
},
|
||||
"navigationBarTitleText": "手动绑定"
|
||||
}
|
||||
25
pages/handleLogin/index.wxml
Normal file
25
pages/handleLogin/index.wxml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--pages/handleLogin/index.wxml-->
|
||||
<topbar />
|
||||
<view>
|
||||
<select label="园区" type="0" bind:choose="onChoosePark" park="{{park}}" parkName="{{parkName}}" required="{{true}}" />
|
||||
<select label="公司名称" type="1" bind:choose="onChooseTenement" park="{{park}}" tenement="{{tenement}}" tenementName="{{tenementName}}" required="{{true}}" />
|
||||
<van-field
|
||||
required
|
||||
value="{{ phone }}"
|
||||
label="联系人手机号"
|
||||
placeholder="请输入联系人手机号"
|
||||
border="{{ false }}"
|
||||
bind:change="onChangePhone"
|
||||
/>
|
||||
<van-field
|
||||
required
|
||||
value="{{ name }}"
|
||||
label="你的昵称"
|
||||
placeholder="请输入你的昵称"
|
||||
border="{{ false }}"
|
||||
bind:change="onChangeName"
|
||||
/>
|
||||
<view class="submit">
|
||||
<van-button type="info" block bind:click="handleSubmit"> 提交 </van-button>
|
||||
</view>
|
||||
</view>
|
||||
5
pages/handleLogin/index.wxss
Normal file
5
pages/handleLogin/index.wxss
Normal file
@@ -0,0 +1,5 @@
|
||||
/* pages/handleLogin/index.wxss */
|
||||
.submit {
|
||||
margin-top: 40rpx;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user