1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- const {
- default: api
- } = require("../../js/api");
- Page({
- data: {
- isLoggedIn: false,
- site:{},
- userInfo: {},
- scanTitle: '扫码加油',
- scanTip: '请扫描加油机键盘上的二维码'
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getSiteInfo()
- },
- onShow(){
- this.getSiteInfo()
- },
- /** 获取站点信息 */
- getSiteInfo(){
- api.request_GetSiteInfo().then(res => {
- if(res.data.statusCode == 203) {
- console.log("获取站点信息失败",res)
- return
- }
- console.log("站点信息",res)
- this.setData({
- isLoggedIn: true,
- site:res.data.data.site,
- userInfo: res.data.data.userInfo,
- scanTitle: '扫码加油',
- scanTip: '请扫码加油机键盘上的二维码'
- })
- }).catch(err => {
- console.log("获取站点信息失败",err)
- })
- },
- toLoginOrOrderPage: function () {
- if (!this.data.isLoggedIn) {
- wx.navigateTo({
- url: '../login/login'
- })
- } else {
- wx.navigateTo({
- url: '../historyOrder/historyOrder?paymentMode=' + this.data.site.paymentMode,
- })
- }
- },
- // 打开扫码功能
- scanCode: function () {
- const that = this;
- wx.scanCode({
- success(res) {
- console.log("扫码内容",res.result)
- const scanStr = res.result;
- if(scanStr.includes('wxapp')) {
- const id = scanStr.split('wxapp?id=')[1];
- wx.redirectTo({
- url: '../TransactionPage/TransactionPage?id=' + id,
- fail(err){
- wx.showToast({
- title: '跳转页面失败',
- icon: 'none'
- });
- }
- })
- }
- if(scanStr.includes('yuwxapp')) {
- const id = scanStr.split('yuwxapp?id=')[1];
- wx.redirectTo({
- url: '../quantify/quantify?id=' + id,
- fail(err){
- wx.showToast({
- title: '跳转页面失败',
- icon: 'none'
- });
- }
- })
- }
-
- },
- fail(err) {
- console.error('扫码失败:', err);
- wx.showToast({
- title: '扫码失败',
- icon: 'none'
- });
- }
- });
- }
- });
|