Commit 6ea1f7ef11237ca43bbe32af3a92f7bf5476d5b0

Authored by 刘淇
1 parent 5e52ed7c

个人中心

src/api/getUserIfo.js
... ... @@ -26,4 +26,30 @@ export function getFeedbackType(params) { // 获取建议反馈类型
26 26 })
27 27 }
28 28  
  29 +export function sendverificode(params) { // 获取手机验证码
  30 + return request({
  31 + url: 'user/sendverificode',
  32 + method: 'post',
  33 + data: params
  34 + })
  35 +}
  36 +
  37 +
  38 +export function bindCustByOpenId(params) { // 绑定手机号获取
  39 + return request({
  40 + url: 'wxPublicUser/bindCustByOpenId',
  41 + method: 'post',
  42 + data: params
  43 + })
  44 +}
  45 +
  46 +export function getOpenIdByCode(params) { // 绑定openId
  47 + return request({
  48 + url: 'weixinPublicPay/getOpenIdByCode',
  49 + method: 'post',
  50 + data: params
  51 + })
  52 +}
  53 +
  54 +
29 55  
... ...
src/utils/utils.js
... ... @@ -74,22 +74,7 @@ export default {
74 74 }
75 75 return time;
76 76 },
77   - // myVxAppId: 'wx1489e48e6a547023',
78   - signObject: function(jsonObj) { //签名字段
79   - jsonObj.sign_type = "md5";
80   - jsonObj.app_id = "ud8yq5tv0inxupc05xfeau39jywlqoj2";
81   - jsonObj.deviceInfo = "BC0703A4-AFB0-4B51-9089-9B7487C0CC6E";
82   - jsonObj.salt = myCommonSalt(32);
83   - jsonObj.token = "99ecd32eed1b4ebea71bc73b0aabbb99";
84   - let sort = [];
85   - for (let k in jsonObj) {
86   - sort.push({
87   - keyname: k,
88   - value: jsonObj[k]
89   - });
90   - }
91   - return this.myGetSign(sort);
92   - },
  77 +
93 78 clientBrowser: function() { // 判断客户端
94 79 if (/MicroMessenger/.test(window.navigator.userAgent)) {
95 80 console.log("微信客户端");
... ... @@ -130,8 +115,27 @@ export default {
130 115 myVarAppid: "ud8yq5tv0inxupc05xfeau39jywlqoj2",// 公共请求Appid
131 116 myDeviceInfo: "BC0703A4-AFB0-4B51-9089-9B7487C0CC6E", // 公共请求设备信息
132 117 myVxAppId: "wx1489e48e6a547023",
133   - openId: "oWw3o5rY_bFsiT_nFd2CEQWGZfhs",
  118 + userToken:localStorage.getItem('userToken'),
  119 + userPhoneNum:localStorage.getItem('userPhoneNum'),
  120 + openId: "",
134 121 myOrgId: "10120", // 归属地 赤峰id 10003 黄石 10079
  122 +
  123 + // myVxAppId: 'wx1489e48e6a547023',
  124 + signObject: function(jsonObj) { //签名字段
  125 + jsonObj.sign_type = "md5";
  126 + jsonObj.app_id = "ud8yq5tv0inxupc05xfeau39jywlqoj2";
  127 + jsonObj.deviceInfo = "BC0703A4-AFB0-4B51-9089-9B7487C0CC6E";
  128 + jsonObj.salt = myCommonSalt(32);
  129 + jsonObj.token = localStorage.getItem('userToken');
  130 + let sort = [];
  131 + for (let k in jsonObj) {
  132 + sort.push({
  133 + keyname: k,
  134 + value: jsonObj[k]
  135 + });
  136 + }
  137 + return this.myGetSign(sort);
  138 + },
135 139 myGetSign: function(objb) { // 获取签名
136 140 var compare = function(obj1, obj2) {
137 141 var val1 = obj1.keyname;
... ...
src/views/binding/binDing.vue
... ... @@ -8,40 +8,145 @@
8 8 </mt-field>
9 9  
10 10 <div style="margin-top: 34px" class="leftRightPadding">
11   - <van-button type="info" block>绑定</van-button>
  11 + <van-button type="info" block @click="bindPhoneHandle">绑定</van-button>
12 12 </div>
13 13 </div>
14 14 </template>
15 15  
16 16 <script>
  17 +
  18 +import { sendverificode, bindCustByOpenId, getOpenIdByCode, getTokenByOpenId } from "@/api/getUserIfo";
17 19 export default {
18   - name: 'binDing',
  20 + name: "binDing",
19 21 data() {
20 22 return {
21   - codeText: '',
22   - phone: '',
23   - timeText: '获取验证码',
  23 + codeText: "",
  24 + phone: "",
  25 + timeText: "获取验证码",
24 26 timeNum: 60,
25   - }
  27 + webAppCode: ""
  28 + };
26 29 },
27   - created(){
28   - this.timeNum = this.timeText
  30 + created() {
  31 + this.timeNum = this.timeText;
  32 + // this.webAppCode = this.getWxCode(); // 正式打开注释
29 33 },
30 34 methods: {
31   - getCode: function () {
32   - var _this = this
  35 + getWxCode() {
  36 + var appID = this.$utils.myVxAppId;
  37 + var code = this.getUrlParam("code");
  38 + var local = window.location.href;
  39 + if (code == null || code === "") {
  40 + window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appID + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
  41 + } else {
  42 + return code;
  43 + }
  44 + },
  45 + getUrlParam(name) { // 获取url里面的参数
  46 + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
  47 + var r = window.location.search.substr(1).match(reg)
  48 + if (r != null) return unescape(r[2])
  49 + return null
  50 + },
  51 + getCode: function() {
  52 + var _this = this;
33 53 // this.timeText = this.timeNum+'S'
34   - let Num = 5
35   - var timer = setInterval(function () {
36   - _this.timeNum = Num-- +'s'
37   - if(Num== -1){
38   - _this.timeNum = '获取验证码'
39   - clearInterval(timer)
  54 + const reg = /^1[3-9]\d{9}$/;
  55 + if (reg.test(this.phone)) {
  56 + _this.sendverificode();
  57 + let Num = 60;
  58 + var timer = setInterval(function() {
  59 + _this.timeNum = Num-- + "s";
  60 + if (Num == -1) {
  61 + _this.timeNum = "获取验证码";
  62 + clearInterval(timer);
  63 + }
  64 + }, 1000);
  65 + } else {
  66 + this.$toast("请输入正确手机号");
  67 + }
  68 + },
  69 + sendverificode() {
  70 + let jsondata = {
  71 + phone: this.phone
  72 + };
  73 + jsondata.sign = this.$utils.signObject(jsondata);
  74 + console.log("停车记录传参 " + JSON.stringify(jsondata));
  75 + sendverificode(jsondata).then(response => {
  76 + console.log(response);
  77 + this.$toast("获取验证码成功");
  78 + });
  79 + },
  80 + bindPhoneHandle() {
  81 + const reg = /^1[3-9]\d{9}$/;
  82 + if (reg.test(this.phone)) {
  83 + this.getOpenIdByCode(); // 获取openid
  84 +
  85 + } else {
  86 + this.$toast("请输入正确手机号");
  87 + }
  88 + },
  89 + getOpenIdByCode() { // 获取openid
  90 +
  91 + this.bindCustByOpenId() // 正式注释
  92 +
  93 +
  94 +
  95 + // 正式打开注释
  96 +
  97 + // let jsondata = {
  98 + // appId: this.$utils.myVxAppId,
  99 + // code: this.webAppCode
  100 + // };
  101 + // jsondata.sign = this.$utils.signObject(jsondata);
  102 + // console.log("停车记录传参 " + JSON.stringify(jsondata));
  103 + // getOpenIdByCode(jsondata).then(response => {
  104 + // if(response.code=='0'){
  105 + // this.bindCustByOpenId() // 获取token和用户手机号
  106 + // }
  107 + // });
  108 + },
  109 + bindCustByOpenId(){ //
  110 + let jsondata = {
  111 + phoneNum: this.phone,
  112 + verifyCode: this.codeText,
  113 + // openid: this.$utils.openId // 正式打开注释
  114 + openid:'oWw3o5rY_bFsiT_nFd2CEQWGZfhs' // 正式注释
  115 + };
  116 + jsondata.sign = this.$utils.signObject(jsondata);
  117 + console.log("停车记录传参 " + JSON.stringify(jsondata));
  118 + bindCustByOpenId(jsondata).then(response => {
  119 + if(response.code=='0'){
  120 + this.getTokenByOpenId() // 获取token和用户手机号
  121 +
  122 + }else if(response.code=='1017'||response.code==1017){
  123 + this.$toast("已经绑定过");
  124 + }else{
  125 + this.$toast("绑定失败");
  126 + }
  127 + });
  128 + },
  129 + getTokenByOpenId(){ // 获取token和用户手机号
  130 + let jsondata = {
  131 + // openid: this.$utils.openId // 正式打开注释
  132 + openid:'oWw3o5rY_bFsiT_nFd2CEQWGZfhs' // 正式注释
  133 + };
  134 + jsondata.sign = this.$utils.signObject(jsondata);
  135 + console.log("停车记录传参 " + JSON.stringify(jsondata));
  136 + getTokenByOpenId(jsondata).then(response => {
  137 + if(response.code=='0'){
  138 + this.$toast("亲,您已绑定成功!");
  139 + localStorage.setItem('userToken',response.data.token)
  140 + localStorage.setItem('userPhoneNum',response.data.phoneNum)
  141 + this.$router.push({
  142 + name: "selfNav"
  143 + }
  144 + );
40 145 }
41   - }, 1000)
  146 + });
42 147 }
43 148 }
44   -}
  149 +};
45 150 </script>
46 151  
47 152 <style scoped lang="scss">
... ...
src/views/mySelf/feedback/suggestionBack.vue
... ... @@ -12,10 +12,6 @@
12 12 </li>
13 13 </ul>
14 14  
15   -
16   -
17   - <!--<mt-field label="" placeholder="请详细描述反馈问题,或提出改进建议。(300字以内)" type="textarea" rows="4" v-model="introduction" ></mt-field>-->
18   -
19 15 <van-field
20 16 v-model="introduction"
21 17 rows="2"
... ... @@ -26,7 +22,7 @@
26 22 show-word-limit
27 23 />
28 24  
29   - <div style="margin-top: 34px">
  25 + <div style="margin-top: 34px">
30 26 <van-button type="info" block @click="submitCon">提交</van-button>
31 27 </div>
32 28 </div>
... ... @@ -34,54 +30,53 @@
34 30  
35 31 <script>
36 32  
37   -import { saveFeedbackAndSuggest, getFeedbackType } from '@/api/getUserIfo'
  33 +import { saveFeedbackAndSuggest, getFeedbackType } from "@/api/getUserIfo";
38 34 export default {
39   - name: 'suggestionBack',
  35 + name: "suggestionBack",
40 36 data() {
41 37 return {
42 38 suggestionList: [],
43 39 currentIndex: 0,
44   - introduction: '',
45   - }
  40 + introduction: ""
  41 + };
46 42 },
47   - created(){
48   - this.getFeedbackType()
  43 + created() {
  44 + this.getFeedbackType();
49 45 },
50 46 methods: {
51   - getFeedbackType(){
52   - let jsondata = {}
53   - jsondata.sign = this.$utils.signObject(jsondata)
  47 + getFeedbackType() {
  48 + let jsondata = {};
  49 + jsondata.sign = this.$utils.signObject(jsondata);
54 50 getFeedbackType(jsondata).then(response => {
55   - console.log(response)
56   - this.suggestionList = response.data
57   - })
  51 + console.log(response);
  52 + this.suggestionList = response.data;
  53 + });
58 54 },
59   - chooseHandle: function (i) {
60   - console.log(i)
61   - this.currentIndex = i
  55 + chooseHandle: function(i) {
  56 + console.log(i);
  57 + this.currentIndex = i;
62 58 },
63   - submitCon(){
64   - if(this.introduction){
  59 + submitCon() {
  60 + if (this.introduction) {
65 61 let jsondata = {
66   - feedbackCode:this.suggestionList[this.currentIndex].code,
67   - suggestDesc:this.introduction,
  62 + feedbackCode: this.suggestionList[this.currentIndex].code,
  63 + suggestDesc: this.introduction
68 64 // token:'99ecd32eed1b4ebea71bc73b0aabbb99'
69   - }
70   - jsondata.sign = this.$utils.signObject(jsondata)
  65 + };
  66 + jsondata.sign = this.$utils.signObject(jsondata);
71 67 saveFeedbackAndSuggest(jsondata).then(response => {
72   - console.log(response)
73   - if(response.code==0){
  68 + console.log(response);
  69 + if (response.code == 0) {
74 70 this.$toast("提交成功");
75 71 }
76 72 // this.phoneNum = response.data.phoneNum
77   - })
78   -
79   - }else{
  73 + });
  74 + } else {
80 75 this.$toast("请填写建议反馈内容");
81 76 }
82 77 }
83 78 }
84   -}
  79 +};
85 80 </script>
86 81  
87 82 <style scoped lang="scss">
... ...
src/views/mySelf/selfNav.vue
... ... @@ -25,9 +25,9 @@
25 25 </van-cell-group>
26 26  
27 27  
28   - <div class="leftRightPadding" style="margin-top: 34px" v-if="openId">
  28 + <div class="leftRightPadding" style="margin-top: 34px" v-if="phoneNum">
29 29 <!--<mt-button type="danger" size="large"></mt-button>-->
30   - <van-button type="info" block>退出账户</van-button>
  30 + <!--<van-button type="info" block>退出账户</van-button>-->
31 31 </div>
32 32 <div class="leftRightPadding" style="margin-top: 34px" v-else>
33 33 <van-button type="info" block @click="toBindingPage">登录绑定</van-button>
... ... @@ -38,7 +38,7 @@
38 38  
39 39 <script>
40 40  
41   -import { getTokenByOpenId } from '@/api/getUserIfo'
  41 +import { getTokenByOpenId } from "@/api/getUserIfo";
42 42 export default {
43 43 name: "selfNav",
44 44 data() {
... ... @@ -58,26 +58,23 @@ export default {
58 58 }
59 59 ],
60 60 openId: "",
61   - phoneNum:'',//手机号
  61 + phoneNum: ""//手机号
62 62 };
63 63 },
64 64 mounted() {
65   - this.openId = this.$utils.openId;
66   - if(this.openId){
67   - this.getTokenAndphoneNum()
68   - }
69   - console.log(this.openId);
  65 + // this.openId = this.$utils.openId;
  66 + // if (this.openId) {
  67 + // this.getTokenAndphoneNum();
  68 + // }
  69 + // console.log(this.openId);
70 70 },
71 71 created() {
72   - // this.carNumber = this.$route.query.carNumber // 获取车牌号
73   - // this.carColor = this.$route.query.carNumberColor // 获取颜色 0:蓝牌;1:黄牌;2:白牌;3:黑牌;4:绿色
74   - // this.currentTabActive = this.$route.query.parkFlag ? this.$route.query.parkFlag : 0 // 0在停 1历史
75   - // console.log(this.carNumber)
76   - // this.parkRecordList(this.carNumber)
  72 + this.phoneNum = this.$utils.userPhoneNum
  73 + console.log(this.$utils.userPhoneNum)
77 74 },
78 75 methods: {
79 76 toNextPage(path) {
80   - if (this.openId) {
  77 + if (this.phoneNum) {
81 78 this.$router.push({
82 79 name: path
83 80 }
... ... @@ -96,17 +93,17 @@ export default {
96 93 }
97 94 );
98 95 },
99   - getTokenAndphoneNum(){
  96 + getTokenAndphoneNum() {
100 97 let jsondata = {
101   - openid: this.$utils.openId,
102   - }
103   - jsondata.sign = this.$utils.signObject(jsondata)
104   - console.log('停车记录传参 ' + JSON.stringify(jsondata));
  98 + openid: this.$utils.openId
  99 + };
  100 + jsondata.sign = this.$utils.signObject(jsondata);
  101 + console.log("停车记录传参 " + JSON.stringify(jsondata));
105 102 getTokenByOpenId(jsondata).then(response => {
106   - console.log(response)
107   - this.phoneNum = response.data.phoneNum
108   - console.log(response.data.token)
109   - })
  103 + console.log(response);
  104 + this.phoneNum = response.data.phoneNum;
  105 + console.log(response.data.token);
  106 + });
110 107 }
111 108 }
112 109 };
... ...