123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // pages/doings/doings.js
- import {
- imgUrl,
- request,
- request2,
- baseUrl
- } from "../api/request"
- import {
- cacheGet
- } from "../../utils/cacheUtil"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl:imgUrl,
- codeImg: '',
- hidden: true
- },
- confirm(){
- this.setData({
- hidden: true
- })
- this.setData({
- codeImg: ''
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- dy(){
- wx.getSetting({
- withSubscriptions: true,
- success (res) {
- console.log(res.subscriptionsSetting)
- if(res.subscriptionsSetting.itemSettings['0Rh0woW2g6Mu6SDwDSs4x2pm6b5Re0xo_7Ugc_3pJps'] == 'accept'){
-
- }
- }
- })
- let that = this
- wx.requestSubscribeMessage({
- tmplIds: ['0Rh0woW2g6Mu6SDwDSs4x2pm6b5Re0xo_7Ugc_3pJps'],
- success (res) {
- if(res['0Rh0woW2g6Mu6SDwDSs4x2pm6b5Re0xo_7Ugc_3pJps']=='accept'){
- wx.request({
- url: baseUrl + '/mini/qrCode/getQrCode?qrcodeSign=nazzd',
- method: 'GET',
- responseType: 'arraybuffer',
- header: {
- 'mini-token':cacheGet('token')
- },
- success: function(res){
- try{
- let str = String.fromCharCode.apply(null, new Uint8Array(res.data));
- str = decodeURIComponent(escape((str)));
- let result = JSON.parse(str)
- if (result.msg == '请重新登录' && !result.result) {
- wx.showModal({
- title: '掌新南岸欢迎您!',
- content: '登录,体验更完整!',
- confirmText: '登录',
- cancelText:"取消",
- success: function (res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '/pages/login/login',
- });
- }if (res.cancel){
- wx.navigateTo({
- url: '/pages/index/index',
- })
- }
- },
- });
- return
- }
- }catch(e){
- console.log(e);
- }
- console.log(res);
- if(res.statusCode == 200){
- let url ="data:image/png;base64," + wx.arrayBufferToBase64(res.data)
- that.setData({
- codeImg : url, //设置data里面的图片url
- })
- that.setData({
- hidden: false
- })
- }else if(res.statusCode == 400){//二维码已经核销
- wx.showToast({
- title: '二维码已使用!',
- })
- }else if(res.statusCode == 401){//获取用户id失败
- wx.showToast({
- title: '异常问题!请退出移除小程序重新扫码二维码!',
- icon: 'error',
- duration: 800
- })
- }
- }
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|