| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import {loginByUserInfo ,Login}from './../../utils/login'
- console.log(Login)
- import Toast from '../../components/vant-ui/toast/toast';
- import {
- subcribe
- } from '../../utils/utils'
- const app = getApp();
- Page({
- options: {
- addGlobalClass: true,
- },
- /**
- * 页面的初始数据
- */
- data: {
- cu_items: [{
- title: '我关注的房源',
- icon: 'house',
- value: '/pages/follow-list/follow-list'
- },
- {
- title: '关于我们',
- icon: 'about',
- value: '/pages/about/about'
- },
- {
- title: '消息订阅',
- icon: 'guanzhu',
- action: 'dingyue',
- value: 'null'
- }
- ],
- user_code: '',
- isLogined: app.globalData.token ? true : false,
- userinfo: app.globalData.userinfo
- },
- Navigator_to(e) {
- const {
- value,
- action
- } = e.currentTarget.dataset
- if (value) {
- if (action === 'dingyue') {
- this.subscribeMessage()
- return
- }
- wx.navigateTo({
- url: value,
- })
- }
- },
- toModifyUser() {
- if (!this.data.isLogined) {
- return
- }
- wx.navigateTo({
- url: '/pages/user-info/user-info',
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (e) {
- this.getSubscribeStatus()
- wx.login({
- success: (res) => {
- this.setData({
- user_code: res.code
- })
- }
- })
- },
- onShow: function () {
- this.setData({
- isLogined: app.globalData.token ? true : false,
- userinfo: app.globalData.userinfo
- });
- },
- getPhoneNumber(e) {
- Login(e, this.data.user_code, true).then(res => {
- this.setData({
- isLogined: app.globalData.token ? true : false,
- userinfo: app.globalData.userinfo
- })
- })
- },
- bindgetuserinfo(e) {
- // login(e, this.data.user_code, true).then(res => {
- loginByUserInfo(e, this.data.user_code, true).then(res => {
- this.setData({
- isLogined: app.globalData.token ? true : false,
- userinfo: app.globalData.userinfo
- })
- })
- },
- getSubscribeStatus() {
- wx.getSetting({
- withSubscriptions: true,
- success: (setting) => {
-
- // if (setting.subscriptionsSetting.itemSettings && setting.subscriptionsSetting.itemSettings['GApxDrE3tPhysRxHEmGHRn-0mvNJXqtZ4znZ8PJnQ8Q']) {
- if (setting.subscriptionsSetting.itemSettings && setting.subscriptionsSetting.itemSettings['zWTBJFpALA3KR3qx1keYJCzJdVtRjFbxrnOJc_Htn-g']) {
- this.setData({
- cu_items: [{
- title: '我关注的房源',
- icon: 'house',
- value: '/pages/follow-list/follow-list'
- },
- {
- title: '关于我们',
- icon: 'about',
- value: '/pages/about/about'
- }
- ]
- })
- }
- },
- })
- },
- subscribeMessage() {
- subcribe().then(res => {
- wx.getSetting({
- withSubscriptions: true,
- success: (setting) => {
- if (setting.subscriptionsSetting.itemSettings && setting.subscriptionsSetting.itemSettings[res.subId]) {
- this.setData({
- cu_items: [{
- title: '我关注的房源',
- icon: 'house',
- value: '/pages/follow-list/follow-list'
- },
- {
- title: '关于我们',
- icon: 'about',
- value: '/pages/about/about'
- }
- ]
- })
- return
- }
- Toast({
- message: '请勾选:总是保持以上选择,不再询问'
- });
- },
- })
- })
- return
- }
- })
|