123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- load:false,
- userInfo: {},
- hasUserInfo: false,
- canIUse: wx.canIUse('button.open-type.getUserInfo'),
- Auctioneer:true,
- wxUserInfo: true,
- bangding:true,
- dataObjs:[],
- storestate: '',
- userHeadUrl: '../../images/userhead.png',
- userName: '',
- mobile: '',
- shop: true,
- deliver: 0,
- pay_money: 0,
- receive: 0,
- balance: 0
- },
- /**
- * 生命周期函数--监听页面加载
- */
- //show.js
- //获取应用实例
- modalcnt:function(){
- wx.showModal({
- title: '提示',
- content: '功能敬请期待',
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- })
- },
- //开店认证
- shop:function(e){
- var _this = this;
- var mobile = wx.getStorageSync('persion').persion.mobile;
- if (mobile) {
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/pm/get_shop_info',
- header: {
- 'ydw-token': wx.getStorageSync('key').ydw_token
- },
- success: function (data) {
-
- if (data.data.tip.msg == "未认证") {
- wx.showModal({
- title: '提示',
- content: '您未有店铺,点击确定进行注册!',
- success: function (res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '../mine/wxml/shopregistration/shopregistration'
- })
- } else if (res.cancel) {
- }
- }
- })
- } else if (data.data.tip.msg == "未审核") {
- wx.showModal({
- title: '提示',
- content: '您的店铺正在审核,请耐心等待1~2个工作日',
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- })
- } else {
- wx.navigateTo({
- url: '../mine/wxml/allthesellers/allthesellers?shopkid=' + data.data.shop.kid + '&name=' + data.data.shop.name
- })
- }
- }
- })
- } else {
- wx.showToast({
- title: '请您先绑定帐号!',
- icon: 'none'
- })
- }
-
- },
- onLoad: function (options) {
- let _this = this;
- var mobile = wx.getStorageSync('persion').persion.mobile;
- if (mobile){
- var nmobile = mobile.substr(0, 3) + '****' + mobile.substring(7, 11);
- _this.setData({
- bangding: false,
- mobile: '已绑定:' + nmobile
- })
- }
- if (this.data.hasUserInfo) {
- _this.setData({
- userInfo: app.globalData.userInfo,
- hasUserInfo: true
- })
- } else if (_this.data.canIUse) {
- _this.setData({
- userInfo: wx.getStorageSync('persion').persion,
- })
-
- } else {
- // 在没有 open-type=getUserInfo 版本的兼容处理
- wx.getUserProfile({
- desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: (res) => {
- app.globalData.userInfo = res.userInfo
- this.setData({
- userInfo: res.userInfo,
- hasUserInfo: true
- })
- }
- })
- };
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/pm/get_shop_info',
- header: {
- 'ydw-token': wx.getStorageSync('key').ydw_token
- },
- success: function (data) {
- _this.setData({
- balance: data.data.balance
- })
- if (data.data.tip.msg == "未认证") {
- _this.setData({
- storestate: '立即注册'
- })
- } else if (data.data.tip.msg == "未审核") {
- _this.setData({
- storestate: '正在审核'
- })
- } else if (data.data.tip.msg == "已认证") {
- _this.setData({
- shopName: data.data.shop.name,
- storestate: '进入店铺',
- shop: false
- })
- }
- }
- });
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/pm/select_count',
- header: {
- 'ydw-token': wx.getStorageSync('key').ydw_token
- },
- method: 'GET',
- dataType: 'json',
- responseType: 'text',
- success: function(data) {
- _this.setData({
- deliver: data.data.wait_deliver > 99 ? 99 : data.data.wait_deliver,
- pay_money: data.data.wait_pay_money > 99 ? 99 : data.data.wait_pay_money,
- receive: data.data.wait_receive > 99 ? 99 : data.data.wait_receive
- })
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if(this.data.load) {
- this.onLoad();
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- this.setData({
- load:true
- })
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- imgClickShow:function(){
- var imgUrl = this.data.userInfo.avatarUrl;
- wx.previewImage({
- urls:[imgUrl],
- success:function(){
- }
- })
- },
- userAuthorize: function () {
- wx.getSetting({
- success: res => {
- if (!res.authSetting['scope.userInfo']) {
- this.setData({
- wxUserInfo: false
- });
- } else {
- this.setData({
- wxUserInfo: true
- });
- }
- }
- })
- },
- getUserProfile(e) {
- let _this = this
- // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
- // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
- wx.getUserProfile({
- desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: (res) => {
- app.globalData.userInfo =res.userInfo
- _this.setData({
- userInfo: res.userInfo,
- hasUserInfo: true
- })
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/pm/update_userinfo',
- data: {
- userinfo: JSON.stringify(res.userInfo)
- },
- header: { 'ydw-token': wx.getStorageSync('key').ydw_token },
- method: 'GET',
- dataType: 'json',
- responseType: 'text',
- success: function (data) {
- wx.setStorageSync('persion', { 'persion': data.data.persion });
- },
- fail: function (res) { }
- })
- }
- })
- },
- })
|