|
@@ -1,6 +1,6 @@
|
|
|
// pages/appointment/appointment.js
|
|
|
const app = getApp()
|
|
|
-import { submitAppointment, getResetNumber } from '../../api/appointment'
|
|
|
+import { submitAppointment, getResetNumber, getAccountNmber } from '../../api/appointment'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -8,6 +8,7 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
hasAddress: false,
|
|
|
+ accountNumber: 0,
|
|
|
addressId: '',
|
|
|
address: '',
|
|
|
province: '',
|
|
@@ -32,6 +33,54 @@ Page({
|
|
|
this.initCalendar()
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow() {
|
|
|
+ this.getAccountNmberFn()
|
|
|
+ if (app.globalData.navigateBackParams.address) {
|
|
|
+ this.setData({
|
|
|
+ hasAddress: true,
|
|
|
+ address: app.globalData.navigateBackParams.address,
|
|
|
+ contactName: app.globalData.navigateBackParams.contactName,
|
|
|
+ contactPhone: app.globalData.navigateBackParams.contactPhone,
|
|
|
+ addressId: app.globalData.navigateBackParams.addressId,
|
|
|
+ province: app.globalData.navigateBackParams.province,
|
|
|
+ city: app.globalData.navigateBackParams.city,
|
|
|
+ county: app.globalData.navigateBackParams.county
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onPullDownRefresh () {
|
|
|
+ wx.vibrateShort({
|
|
|
+ type: 'medium'
|
|
|
+ })
|
|
|
+ this.getAccountNmberFn(true)
|
|
|
+ },
|
|
|
+ // 查询账户剩余可使用的次数
|
|
|
+ getAccountNmberFn (pullDownRefresh = false) {
|
|
|
+ var that = this
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中...',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ getAccountNmber({}).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ if (pullDownRefresh) {
|
|
|
+ wx.stopPullDownRefresh()
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ accountNumber: res.data
|
|
|
+ })
|
|
|
+ }).catch(e => {
|
|
|
+ wx.hideLoading()
|
|
|
+ wx.showModal({
|
|
|
+ content: e,
|
|
|
+ confirmColor: '#333',
|
|
|
+ showCancel: false
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
// 初始化日历
|
|
|
async initCalendar () {
|
|
|
var that = this
|
|
@@ -161,23 +210,7 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow() {
|
|
|
- if (app.globalData.navigateBackParams.address) {
|
|
|
- this.setData({
|
|
|
- hasAddress: true,
|
|
|
- address: app.globalData.navigateBackParams.address,
|
|
|
- contactName: app.globalData.navigateBackParams.contactName,
|
|
|
- contactPhone: app.globalData.navigateBackParams.contactPhone,
|
|
|
- addressId: app.globalData.navigateBackParams.addressId,
|
|
|
- province: app.globalData.navigateBackParams.province,
|
|
|
- city: app.globalData.navigateBackParams.city,
|
|
|
- county: app.globalData.navigateBackParams.county
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
/**
|
|
|
* 选择地址
|
|
|
*/
|
|
@@ -210,7 +243,26 @@ Page({
|
|
|
handleCharge () {},
|
|
|
// 确定 先查询 区域的剩余预约次数
|
|
|
handleConfirm () {
|
|
|
- if (!this.data.hasAddress) {
|
|
|
+ if (this.data.accountNumber == 0) {
|
|
|
+ wx.showModal({
|
|
|
+ content: '您当前的检测次数为0,先充值次数',
|
|
|
+ cancelColor: '#666',
|
|
|
+ cancelText: '卡激活',
|
|
|
+ confirmText: '去充值',
|
|
|
+ confirmColor: '#333',
|
|
|
+ success (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/buy/buy?form=appointment',
|
|
|
+ })
|
|
|
+ } else if (res.cancel) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/scan/scan?form=appointment',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (!this.data.hasAddress) {
|
|
|
wx.showToast({
|
|
|
title: '请选择地址',
|
|
|
icon: 'error',
|