123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- // pages/setting/index.js
- /**
- * 设置
- */
- import * as API_Shop from '../../api/shop.js'
- import * as Common from '../../utils/common.js'
- import * as API_Passport from '../../api/passport.js'
- const app=getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- bool_bind:false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const that = this
- that.getTabBar().init()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- const that = this
- that.getTabBar().init()
- that.setData({
- bool_bind:app.globalData.authorInfo.bool_bind
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- logout(e){
- API_Passport.logout({'uid':app.globalData.authorInfo.uid}).then(res=>{
- wx.removeStorageSync('authorInfo')
- wx.removeStorageSync('sellerUser')
- wx.removeStorageSync('sellerShop')
- wx.removeStorageSync('login_result')
- app.globalData.authorInfo = {}
- app.globalData.sellerUser = {}
- app.globalData.sellerShop = {}
- //退出登录 会清除redis授权缓存,自动登录一下,把redis授权重新写入,以防用户又直接登录
- // Common.toAutoLogin()
- wx.redirectTo({
- url: '/pages/login/login',
- })
- })
- },
- onStateChange: function(e) {
- const that=this
- wx.login({
- success(res){
- const param={
- mini_program_type:app.globalData.miniProgramType,
- uuid:app.globalData.uuid,
- uid:app.globalData.authorInfo.uid,
- code:res.code
- }
- if(e.detail.value){//绑定
- API_Passport.bindUser(param).then(res=>{
- app.globalData.authorInfo.bool_bind=1
- wx.setStorageSync('authorInfo',app.globalData.authorInfo)
- that.setData({
- bool_bind: e.detail.value
- })
- }).catch(err=>{
- console.log(err)
- })
- }else{ //解绑
- API_Passport.unbindUser(param).then(res=>{
- app.globalData.authorInfo.bool_bind=0
- wx.setStorageSync('authorInfo',app.globalData.authorInfo)
- that.setData({
- bool_bind: e.detail.value
- })
- }).catch(err=>{
- console.log(err)
- })
- }
- }
- })
- },
- subscribeMessage(e){
- console.log(e)
- wx.requestSubscribeMessage({
- tmplIds: ['Y2LCDRXld1ccrdmPavW4gBi1RhI8rjVyeOUencmPMpw'],
- success (res) {
- console.log(res)
- },
- complete(res){
- console.log(res)
- }
- })
- }
- })
|