123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- const app = getApp()
- const link = app.globalData.url
- Page({
- data: {
- grids1: [{
- image: 'order',
- text: '我的订单'
- }, {
- image: 'user',
- text: '好友列表'
- }, {
- image: 'help',
- text: '帮助中心'
- }, {
- image: 'add',
- text: '邀请好友'
- }, {
- image: 'to-top',
- text: '手动同步订单'
- }, {
- image: 'customer-service',
- text: '联系客服'
- }, {
- image: 'setting',
- text: '设置'
- },
- {
- image: 'success',
- text: '提现'
- },
-
-
-
-
-
-
-
- ],
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- motto: 'Hello World',
- userInfo: {},
- hasUserInfo: false,
- canIUse: wx.canIUse('button.open-type.getUserInfo'),
- canIUseGetUserProfile: false,
- canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName')
- },
-
- bindViewTap() {
- wx.navigateTo({
- url: '../logs/logs'
- })
- },
- onLoad() {
- var that = this
- var opneId = wx.getStorageSync('openId')
- var nickName = wx.getStorageSync('nickName')
- if (wx.getUserProfile) {
- this.setData({
- canIUseGetUserProfile: true
- })
- }
-
- wx.request( {
- url: link + "/v1/user/wallet/get",
- header: {
- "Content-Type": "application/json"
- },
- method: "POST",
- data: { openId: opneId },
- success (res) {
- console.log(res)
-
- that.setData({
- wallet: res.data.data.wallet
- })
-
- }
- })
-
- console.log(nickName)
- if (nickName == ''){
- wx.request( {
- url: link + "/v1/user/open.id/get",
- header: {
- "Content-Type": "application/json"
- },
- method: "POST",
- data: { openId: opneId },
- success (res) {
- console.log(res)
- wx.setStorageSync('nickName', res.data.data.user.nickName)
- wx.setStorageSync('userId', res.data.data.user.id)
- that.setData({
- userId: res.data.data.user.id
- })
- }
- })
- } else{
- var userId = wx.getStorageSync('userId')
- console.log(userId)
- that.setData({
- userId: userId
- })
- }
- },
- clickGrid(e) {
- var that = this
- console.log(e)
- if (e.detail.cell.text == "我的订单"){
- wx.navigateTo({
- url:"/pages/order/order"
- })
- } else if (e.detail.cell.text == "联系客服"){
- wx.showModal({
- title: '客服微信',
- content: '客服微信:tao1024_com,点击复制按钮,直接复制客服微信号,粘贴到微信中搜索添加客服.',
- showCancel: true,
- cancelText:"取消",
-
- confirmText:"复制",
-
- success: function (res) {
- if (res.cancel) {
-
- } else {
- wx.setClipboardData({
- data: 'tao1024_com',
- success (res) {
-
- wx.showToast({
- title: '复制成功',
- duration:2000,
- mask:true,
- icon:'success',
- success:function(){ },
- fail: function () { },
- complete: function () { }
- })
- }
- })
-
-
- }
- },
- fail: function (res) { },
- complete: function (res) { },
- })
- }
- else if (e.detail.cell.text == "提现") {
- wx.showToast({
- title: "结算金额:0元",
- icon: 'none'
- });
- } else if (e.detail.cell.text == "邀请好友"){
- console.log('邀请好友')
- wx.navigateTo({
- url:"/pages/friends/friends"
- })
- } else if (e.detail.cell.text == "好友列表"){
- wx.navigateTo({
- url:"/pages/friends-list/friends-list"
- })
- }
-
- else {
- wx.showToast({
- title: "功能开发中...",
- icon: 'none'
- });
- }
-
- },
- getUserProfile(e) {
- var that = this
- var openId = wx.getStorageSync('openId')
- var nickName = wx.getStorageSync('nickName')
- console.log("'"+nickName+"'")
- console.log(openId)
- if (nickName == ''){
- wx.getUserProfile({
- desc: '展示用户信息',
- success: (res) => {
- console.log(res)
-
- wx.request( {
- url: link + "/v1/user/update/name",
- header: {
- "Content-Type": "application/json"
- },
- method: "POST",
- data: { openId: openId ,nickName:res.userInfo.nickName,avatarUrl:res.userInfo.avatarUrl},
- success (ress) {
- console.log(ress)
- wx.setStorageSync('nickName', res.userInfo.nickName)
-
- }
- })
- that.clickGrid(e)
- }
- })
- } else{
- that.clickGrid(e)
- }
-
-
-
- },
- getUserInfo(e) {
-
- console.log(e)
- this.setData({
- userInfo: e.detail.userInfo,
- hasUserInfo: true
- })
- },
-
-
-
-
-
-
-
-
-
- })
|