// pages/guide/index.js require('regenerator-runtime'); import { request, login } from '../../utils/request'; import { judgeMyApi } from '../../utils/util/index' Page({ data: { isLogin: false, list: [{ name: '基础业务功能', url: '/packageA/base_function/index' }, { name: '点击获取设备列表', url: '/packageA/home_center/device_list/index' }, ], background: [ 'https://unpkg.com/@vant/assets/apple-1.jpeg', 'https://unpkg.com/@vant/assets/apple-2.jpeg', 'https://unpkg.com/@vant/assets/apple-2.jpeg', ], gridList: [ { id: 'manage', name: '帐号管理' }, { id: 'pay', name: '燃气缴费' }, { id: 'history', name: '历史账单' }, { id: 'analyze', name: '用气分析' }, { id: 'place', name: '服务网点' }, { id: 'subsidy', name: '采暖补贴' }, ], gridTwoList: [ { id: 'kefu', name: '客服电话', icon: '../../static/index/kefu.png' }, { id: 'qiangxiu', name: '抢修电话', icon: '../../static/index/weixiu.png' }, ] }, onLoad: async function (options) { await this.wxLogin(); this.setData({ isLogin: true }); let access_token = await wx.getStorageSync('access_token'); if(!access_token) return; // try { // await request({ // data: { // action: 'device.virtualAdd', // params: { // product_id: 'qkxb0pmel0q1g9yf', // token: 'release_common_component' // } // } // }).then(async (res) => { // const { // device_id // } = res; // if (!device_id) return; // this.setData({ // isLogin: true // }); // wx.setStorageSync('vir_device', device_id); // }); // } catch (error) { // // wx.showModal({ // // title: '检测到未部署SDK', // // content: '后续功能操作都需要SDK能力, 请去涂鸦开发平台程序一键部署SDK' // // }) // this.setData({ // isLogin: false // }); // } }, onShow: async function () { if(!this.data.isLogin) { await this.wxLogin(); } wx.getStorageSync('access_token') && this.setData({ isLogin: true }); }, onClickHide: function () { this.setData({ show: false }); }, wxLogin: async function () { let canIuse = await judgeMyApi({myApi:'getUserProfile',myVersion:'2.24.0'}); if(!canIuse) return false; wx.showLoading({ title: '正在登陆', }) const res = await login(); wx.hideLoading(); if (res) { wx.showToast({ title: '登录成功', duration: 1000 }) this.setData({ isLogin: true }) return true; } let timer = setTimeout(() => { wx.showToast({ title: '登录失败', icon: 'error', duration: 1000 }) clearTimeout(timer); return false; }, 1800); }, gotoOtherage: function (event) { const { dataset: { url } } = event.currentTarget; if (url == 'navigateToMiniProgram') { this.setData({ show: true }); } else { wx.navigateTo({ url }); } }, //拨打电话 call(event) { let phone = '010-96777'; console.log('打电话',value); const { dataset: { value } } = event.currentTarget; if(value === 'kefu') { phone: '010-96777'; } else { phone: '010-96777'; } wx.makePhoneCall({ phoneNumber: phone }) }, });