|
@@ -22,79 +22,14 @@ Page({
|
|
|
interval: 5000,
|
|
|
duration: 500,
|
|
|
number: {},
|
|
|
- msgList: [
|
|
|
- // {
|
|
|
- // url: "url",
|
|
|
- // title: "欢迎来到吉顺致养小程序"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // url: "url",
|
|
|
- // title: "欢迎来到吉顺致养小程序"
|
|
|
- // },
|
|
|
- ]
|
|
|
+ msgList: []
|
|
|
},
|
|
|
goCollect() {
|
|
|
- // if (wx.getStorageSync('user') == '') {
|
|
|
- // wx.showModal({
|
|
|
- // showCancel: false,
|
|
|
- // content: '当前您未登录,请登录',
|
|
|
- // success(res) {
|
|
|
- // if (res.confirm) {
|
|
|
- // wx.redirectTo({
|
|
|
- // url: '/pages/login/login',
|
|
|
- // })
|
|
|
- // } else if (res.cancel) {
|
|
|
- // console.log('用户点击取消')
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/collectInfo/collectInfo',
|
|
|
- // })
|
|
|
- // }
|
|
|
- // if (wx.getStorageSync('user') == '') {
|
|
|
- // wx.redirectTo({
|
|
|
- // url: '/pages/login/login',
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/collectInfo/collectInfo',
|
|
|
- // })
|
|
|
- // }
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/userBook/userBook',
|
|
|
})
|
|
|
},
|
|
|
goXunfang() {
|
|
|
- // if (wx.getStorageSync('user') == '') {
|
|
|
- // wx.showModal({
|
|
|
- // showCancel: false,
|
|
|
- // content: '当前您未登录,请登录',
|
|
|
- // success(res) {
|
|
|
- // if (res.confirm) {
|
|
|
- // wx.redirectTo({
|
|
|
- // url: '/pages/login/login',
|
|
|
- // })
|
|
|
- // } else if (res.cancel) {
|
|
|
- // console.log('用户点击取消')
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/visitandinfo/visitandinfo',
|
|
|
- // })
|
|
|
- // }
|
|
|
- // if (wx.getStorageSync('user') == '') {
|
|
|
- // wx.redirectTo({
|
|
|
- // url: '/pages/login/login',
|
|
|
- // })
|
|
|
- // } else {
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/visitandinfo/visitandinfo',
|
|
|
- // })
|
|
|
- // }
|
|
|
if (!wx.getStorageSync('openId')) {
|
|
|
wx.login({
|
|
|
success: res => {
|
|
@@ -150,54 +85,163 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
goTongzhi() {
|
|
|
- if (wx.getStorageSync('user') == '') {
|
|
|
- wx.redirectTo({
|
|
|
- url: '/pages/login/login',
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/notice/notice',
|
|
|
- })
|
|
|
- }
|
|
|
+ wx.login({
|
|
|
+ success: (res) => {
|
|
|
+ if (res.code) {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/wx/getAppletOpenId',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ cid: 'applet',
|
|
|
+ code: res.code
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ // 获取到用户的 openid
|
|
|
+ if (res.data.status == 200) {
|
|
|
+ wx.setStorageSync('openId', res.data.data.openid)
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/applet/isExist',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log('app登录是否绑定的', res.data.code);
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/notice/notice',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/pages/login/login',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('获取用户登录态失败!' + res.errMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // if (wx.getStorageSync('user') == '') {
|
|
|
+ // wx.redirectTo({
|
|
|
+ // url: '/pages/login/login',
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // wx.navigateTo({
|
|
|
+ // url: '/pages/notice/notice',
|
|
|
+ // })
|
|
|
+ // }
|
|
|
},
|
|
|
goPaiming() {
|
|
|
- if (wx.getStorageSync('user') == '') {
|
|
|
- wx.redirectTo({
|
|
|
- url: '/pages/login/login',
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/paiming/paiming',
|
|
|
- })
|
|
|
- }
|
|
|
+ wx.login({
|
|
|
+ success: (res) => {
|
|
|
+ if (res.code) {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/wx/getAppletOpenId',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ cid: 'applet',
|
|
|
+ code: res.code
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ // 获取到用户的 openid
|
|
|
+ if (res.data.status == 200) {
|
|
|
+ wx.setStorageSync('openId', res.data.data.openid)
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/applet/isExist',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log('app登录是否绑定的', res.data.code);
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/paiming/paiming',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/pages/login/login',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('获取用户登录态失败!' + res.errMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
goSaoMa() {
|
|
|
- console.log("扫阿");
|
|
|
- if (wx.getStorageSync('user') == '') {
|
|
|
- wx.redirectTo({
|
|
|
- url: '/pages/login/login',
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.scanCode({
|
|
|
- onlyFromCamera: true,
|
|
|
- success: (res) => {
|
|
|
- console.log(res, "扫码成功");
|
|
|
- let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/love/love?id=' + length,
|
|
|
- })
|
|
|
- },
|
|
|
- fail: (res) => {
|
|
|
- console.log(res, "扫码失败");
|
|
|
- wx.showToast({
|
|
|
- title: '扫码失败',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000,
|
|
|
- })
|
|
|
+ wx.login({
|
|
|
+ success: (res) => {
|
|
|
+ if (res.code) {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/wx/getAppletOpenId',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ cid: 'applet',
|
|
|
+ code: res.code
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ // 获取到用户的 openid
|
|
|
+ if (res.data.status == 200) {
|
|
|
+ wx.setStorageSync('openId', res.data.data.openid)
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/applet/isExist',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log('app登录是否绑定的', res.data.code);
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data) {
|
|
|
+ wx.scanCode({
|
|
|
+ onlyFromCamera: true,
|
|
|
+ success: (res) => {
|
|
|
+ console.log(res, "扫码成功");
|
|
|
+ let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/love/love?id=' + length,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: (res) => {
|
|
|
+ console.log(res, "扫码失败");
|
|
|
+ wx.showToast({
|
|
|
+ title: '扫码失败',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/pages/login/login',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('获取用户登录态失败!' + res.errMsg);
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
depts() {
|
|
|
console.log("1111111111111111111111111111");
|
|
@@ -222,56 +266,140 @@ Page({
|
|
|
this.setData({
|
|
|
msgList: []
|
|
|
})
|
|
|
- if (wx.getStorageSync('user') == '') {
|
|
|
- wx.request({
|
|
|
- url: app.globalData.publicUrl + '/welcomeMessage/list',
|
|
|
- method: "GET",
|
|
|
- success: (res) => {
|
|
|
- if (res.data.code == 0) {
|
|
|
- if (res.data.data.length != 0) {
|
|
|
- let result = res.data.data[0].title
|
|
|
- this.data.msgList.push({
|
|
|
- title: result
|
|
|
- });
|
|
|
- this.data.msgList.push({
|
|
|
- title: result
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- msgList: this.data.msgList
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.request({
|
|
|
- url: app.globalData.publicUrl + '/appletNotice/listForAppletsFirst',
|
|
|
- method: "GET",
|
|
|
- header: {
|
|
|
- appletsId: wx.getStorageSync('openId')
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- if (res.data.code == 0) {
|
|
|
- if (res.data.data.length == 0) {
|
|
|
- this.data.msgList.push({
|
|
|
- title: '暂无通知'
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- msgList: this.data.msgList
|
|
|
- })
|
|
|
- } else {
|
|
|
- let result = res.data.data.title;
|
|
|
- this.data.msgList.push({
|
|
|
- title: result
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- msgList: this.data.msgList
|
|
|
- })
|
|
|
+ wx.login({
|
|
|
+ success: (res) => {
|
|
|
+ if (res.code) {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/wx/getAppletOpenId',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ cid: 'applet',
|
|
|
+ code: res.code
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ // 获取到用户的 openid
|
|
|
+ if (res.data.status == 200) {
|
|
|
+ wx.setStorageSync('openId', res.data.data.openid)
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/applet/isExist',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log('app登录是否绑定的', res.data.code);
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data) {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/appletNotice/listForAppletsFirst',
|
|
|
+ method: "GET",
|
|
|
+ header: {
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data.length == 0) {
|
|
|
+ this.data.msgList.push({
|
|
|
+ title: '暂无通知'
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ msgList: this.data.msgList
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let result = res.data.data.title;
|
|
|
+ this.data.msgList.push({
|
|
|
+ title: result
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ msgList: this.data.msgList
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/welcomeMessage/list',
|
|
|
+ method: "GET",
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data.length != 0) {
|
|
|
+ let result = res.data.data[0].title
|
|
|
+ this.data.msgList.push({
|
|
|
+ title: result
|
|
|
+ });
|
|
|
+ this.data.msgList.push({
|
|
|
+ title: result
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ msgList: this.data.msgList
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('获取用户登录态失败!' + res.errMsg);
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // if (wx.getStorageSync('user') == '') {
|
|
|
+ // wx.request({
|
|
|
+ // url: app.globalData.publicUrl + '/welcomeMessage/list',
|
|
|
+ // method: "GET",
|
|
|
+ // success: (res) => {
|
|
|
+ // if (res.data.code == 0) {
|
|
|
+ // if (res.data.data.length != 0) {
|
|
|
+ // let result = res.data.data[0].title
|
|
|
+ // this.data.msgList.push({
|
|
|
+ // title: result
|
|
|
+ // });
|
|
|
+ // this.data.msgList.push({
|
|
|
+ // title: result
|
|
|
+ // });
|
|
|
+ // this.setData({
|
|
|
+ // msgList: this.data.msgList
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // wx.request({
|
|
|
+ // url: app.globalData.publicUrl + '/appletNotice/listForAppletsFirst',
|
|
|
+ // method: "GET",
|
|
|
+ // header: {
|
|
|
+ // appletsId: wx.getStorageSync('openId')
|
|
|
+ // },
|
|
|
+ // success: (res) => {
|
|
|
+ // if (res.data.code == 0) {
|
|
|
+ // if (res.data.data.length == 0) {
|
|
|
+ // this.data.msgList.push({
|
|
|
+ // title: '暂无通知'
|
|
|
+ // });
|
|
|
+ // this.setData({
|
|
|
+ // msgList: this.data.msgList
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // let result = res.data.data.title;
|
|
|
+ // this.data.msgList.push({
|
|
|
+ // title: result
|
|
|
+ // });
|
|
|
+ // this.setData({
|
|
|
+ // msgList: this.data.msgList
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
},
|
|
|
onShow() {
|
|
|
this.depts();
|