| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import login from '../../utils/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
- });
- },
- bindgetphonenumber (e) {
- login(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']) {
- 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
- }
- })
|