From 48e1a652680d86d559a69c0c1c4516b96e2291c7 Mon Sep 17 00:00:00 2001 From: meo <958484406@qq.com> Date: Thu, 30 Aug 2018 17:13:04 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF=E6=8E=88?= =?UTF-8?q?=E6=9D=83=20=E4=B8=AA=E4=BA=BA=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E6=8E=88=E6=9D=83=20=E7=99=BB=E9=99=86=E9=A1=B5=E9=9D=A2][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:=20=E4=B8=89=E4=B8=AA=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E5=95=86=E6=88=B7logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.js | 13 ++++-- pages/coupon/detail/index.js | 26 ++++++++++- pages/getphoneInfo/index.js | 86 +++++++++++++++++++++-------------- pages/getphoneInfo/index.wxml | 8 +--- pages/getuserinfo/index.js | 51 +++++++++++++-------- pages/getuserinfo/index.wxml | 11 +---- pages/login/index.js | 37 +++++++++------ pages/login/index.wxml | 2 +- pages/login/index.wxss | 1 + pages/user/index.js | 9 ++-- 10 files changed, 149 insertions(+), 95 deletions(-) diff --git a/config/config.js b/config/config.js index 4b30cad..5b21c0a 100755 --- a/config/config.js +++ b/config/config.js @@ -1,7 +1,7 @@ var config = { - name: "富茂", + name: "富茂科技", url: "https://ciformall.youlane.cn/C/api", - //url: "http://fd1a0cab.ngrok.io/C/api", + // url: "http://fd1a0cab.ngrok.io/C/api", api: { /** * 接口用途:login @@ -120,7 +120,14 @@ var config = { /** * banner详情页面 */ - bannerDetail: "/wxCampaign/findById" + bannerDetail: "/wxCampaign/findById", + /** + * 授权个人信息 + * 和授权手机号 + * 和login页面 + * 页面的图标 + */ + marketicon:'/mall/getAppIcon' }, weapp: { diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index c292d30..59f319a 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -132,7 +132,7 @@ Page({ console.log(that.data.couponChannelId); console.log(that.data.couponId); console.log("我即将要跳转到用户手机号授权的页面"); - if (err.code == "3002") { + if (err.code == "3001") { wx.showToast({ title: "领取达到上限", image: "./../../../assets/img/fail.png", @@ -140,6 +140,30 @@ Page({ mask: false }); } + if (err.code == "3002") { + wx.showToast({ + title: "订单失败", + image: "./../../../assets/img/fail.png", + duration: 2000, + mask: false + }); + } + if (err.code == "3003") { + wx.showToast({ + title: "订单不存在", + image: "./../../../assets/img/fail.png", + duration: 2000, + mask: false + }); + } + if (err.code == "3004") { + wx.showToast({ + title: "订单不存在", + image: "./../../../assets/img/fail.png", + duration: 2000, + mask: false + }); + } if (err.code == "4003") { wx.showToast({ title: "卡券已作废", diff --git a/pages/getphoneInfo/index.js b/pages/getphoneInfo/index.js index f7148e3..f26ae5a 100755 --- a/pages/getphoneInfo/index.js +++ b/pages/getphoneInfo/index.js @@ -1,11 +1,11 @@ -var config = require('../../config/config.js'); +var config = require("../../config/config.js"); const Http = require("../../utils/HttpBasics"); var app = getApp(); Page({ data: { - canIUse: wx.canIUse('button.open-type.getPhoneNumber'), + canIUse: wx.canIUse("button.open-type.getPhoneNumber"), couponChannelId: "", - couponId:"" + couponId: "" }, onLoad: function(options) { var that = this; @@ -13,41 +13,59 @@ Page({ that.setData({ couponChannelId: options.couponChannelId, couponId: options.couponId - }) + }); + + Http.get({ + url: config.api.marketicon, + data: { + appId: config.weapp.AppId + } + }).then(res => { + console.log(res.data.mallImgUrl); + that.setData({ + mallImgUrl: res.data.mallImgUrl + }); + }); }, getPhoneNumber: function(e) { var that = this; var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; Http.post({ - url: config.api.getUserPhone, - data: { - encryptedData: encryptedData, - iv: iv, - } - }) - .then(function(res) { - console.log(res); - console.log("这是用户授权手机号的结果") - console.log(that.data.couponChannelId) - console.log(that.data.couponId) - console.log("这是从立即支付传回来的值 因为用户没有授权手机号") - app.globalData.phone = res.data.phone; - wx.showToast({ - title: res.data.msg, - icon: "success", - success: function(res) { - wx.redirectTo({ - url: '/pages/coupon/detail/index?couponChannelId='+ that.data.couponChannelId + '&couponId='+ that.data.couponId +'&flag=pay' - }) - } - }) - }, - function(error) { - wx.showToast({ - title: '请重新授权手机号', - icon: "none", - }) - }) + url: config.api.getUserPhone, + data: { + encryptedData: encryptedData, + iv: iv + } + }).then( + function(res) { + console.log(res); + console.log("这是用户授权手机号的结果"); + console.log(that.data.couponChannelId); + console.log(that.data.couponId); + console.log("这是从立即支付传回来的值 因为用户没有授权手机号"); + app.globalData.phone = res.data.phone; + wx.showToast({ + title: res.data.msg, + icon: "success", + success: function(res) { + wx.redirectTo({ + url: + "/pages/coupon/detail/index?couponChannelId=" + + that.data.couponChannelId + + "&couponId=" + + that.data.couponId + + "&flag=pay" + }); + } + }); + }, + function(error) { + wx.showToast({ + title: "请重新授权手机号", + icon: "none" + }); + } + ); } -}) \ No newline at end of file +}); diff --git a/pages/getphoneInfo/index.wxml b/pages/getphoneInfo/index.wxml index 2567ef5..dacfea7 100755 --- a/pages/getphoneInfo/index.wxml +++ b/pages/getphoneInfo/index.wxml @@ -1,12 +1,6 @@ - - diff --git a/pages/getuserinfo/index.js b/pages/getuserinfo/index.js index f671631..66a64b8 100755 --- a/pages/getuserinfo/index.js +++ b/pages/getuserinfo/index.js @@ -1,38 +1,51 @@ -var config = require('../../config/config.js'); +var config = require("../../config/config.js"); var app = getApp(); const Http = require("../../utils/HttpBasics"); Page({ data: { - canIUse: wx.canIUse('button.open-type.getUserInfo') + canIUse: wx.canIUse("button.open-type.getUserInfo") }, onLoad: function(options) { var that = this; + Http.get({ + url: config.api.marketicon, + data: { + appId: config.weapp.AppId + } + }).then(res => { + console.log(res.data.mallImgUrl); + that.setData({ + mallImgUrl: res.data.mallImgUrl + }); + }); }, bindGetUserInfo: function(e) { console.log(e); var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; - console.log(iv) - console.log(encryptedData) + console.log(iv); + console.log(encryptedData); Http.post({ - url: config.api.getUserInfo, - data: { - encryptedData: encryptedData, - iv: iv, - } - }) - .then(function(res) { + url: config.api.getUserInfo, + data: { + encryptedData: encryptedData, + iv: iv + } + }).then( + function(res) { console.log(res); //返回主页 wx.switchTab({ - url: '/pages/index/index', - }) - }, function(error) { + url: "/pages/index/index" + }); + }, + function(error) { wx.showToast({ - title: '请授权个人信息', + title: "请授权个人信息", icon: "none" - }) - }) - }, -}) \ No newline at end of file + }); + } + ); + } +}); diff --git a/pages/getuserinfo/index.wxml b/pages/getuserinfo/index.wxml index a2e4a28..a92d189 100755 --- a/pages/getuserinfo/index.wxml +++ b/pages/getuserinfo/index.wxml @@ -1,15 +1,6 @@ - - -