123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- import { homePage } from '../../api/index'
- import { userEntityRecharge } from '../../api/charge'
- import { createQRcode } from "../../api/document";
- const app = getApp()
- Page({
-
- data: {
- locationStr: '定位地址…',
- useNumber: 0,
- documentVos: [],
- cardNo: '',
- cardSecret: '',
- scanTimer: null,
- baseStr: 'data:image/jpg;base64,',
- QRCodeBase64: '',
- qrcodeDialog: false
- },
-
- onShow () {
- if (app.globalData.userInfo.login) {
- this.initIndexData()
- } else {
- wx.reLaunch({
- url: '/pages/my/my'
- })
- }
- },
- onPullDownRefresh () {
- wx.vibrateShort({
- type: 'medium'
- })
- this.initIndexData(true)
- },
- onShareAppMessage () {
- return {
- title: 'ITTHealth',
- path: '/pages/index/index'
- }
- },
-
- initIndexData (pullDownRefresh = false) {
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- homePage({}).then(hoemRes => {
- wx.hideLoading()
- if (pullDownRefresh) {
- wx.stopPullDownRefresh()
- }
- var response = hoemRes.data.documentVos
- response.map(item => {
- item.birthDay = item.birthday.split(' ')[0]
- })
- this.setData({
- useNumber: hoemRes.data.useNumber,
- documentVos: response
- })
- }).catch(e => {
- wx.hideLoading()
- wx.showModal({
- content: e,
- confirmColor: '#333',
- showCancel: false
- })
- })
- },
-
- openMap () {
- wx.chooseLocation()
- },
-
- handlePackage () {
- var type = this.data.useNumber > 0 ? 1 : 0
- switch (type) {
- case 0:
- wx.navigateTo({
- url: '/pages/buy/buy',
- })
- break;
- case 1:
- wx.navigateTo({
- url: '/pages/appointment/appointment',
- })
- break;
- }
- },
-
- handleAllFile () {
- wx.navigateTo({
- url: '/pages/myFile/myFile',
- })
- },
-
- handleAddCheck () {
- wx.navigateTo({
- url: '/pages/createFile/createFile?form=index',
- })
- },
-
- handlActions () {
- if (this.data.useNumber == 0) {
- wx.showModal({
- title: '去充值',
- cancelColor: '#666',
- cancelText: '激活卡',
- confirmText: '去充值',
- confirmColor: '#333',
- success (res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '/pages/buy/buy?form=index',
- })
- } else if (res.cancel) {
- wx.navigateTo({
- url: '/pages/exchange/exchange',
- })
- }
- }
- })
- } else {
- wx.navigateTo({
- url: '/pages/appointment/appointment'
- })
- }
- },
- handleShowQRCode (e) {
- var that = this
- var id = e.currentTarget.dataset.id
- wx.showLoading({
- title: '生成中...'
- })
- createQRcode({ documentId: id }).then(res => {
- wx.hideLoading()
- that.setData({
- QRCodeBase64: that.data.baseStr + res.data,
- qrcodeDialog: true
- })
- }).catch(e => {
- wx.hideLoading()
- wx.showModal({
- content: e,
- confirmColor: '#333',
- showCancel: false
- })
- })
- },
- handleCloseQRCode (e) {
- this.setData({
- qrcodeDialog: false,
- QRCodeBase64: ''
- })
- }
- })
|