Commit 71ca44b6e1a28da1b01af64a4e3e80b6a3986725

Authored by 刘淇
1 parent 3e498dc1

个人中心

config/index.js
... ... @@ -58,7 +58,7 @@ module.exports = {
58 58 * Source Maps
59 59 */
60 60  
61   - productionSourceMap: false,
  61 + productionSourceMap: true,
62 62 // https://webpack.js.org/configuration/devtool/#production
63 63 devtool: '#source-map',
64 64  
... ...
src/api/binDing/binding.js 0 → 100644
  1 +import request from '@/utils/request'
  2 +
  3 +
  4 +// 获取验证码
  5 +export function sendverificode(params) {
  6 + return request({
  7 + url: 'user/sendverificode',
  8 + method: 'post',
  9 + data: params
  10 + })
  11 +}
  12 +
  13 +// 绑定手机号
  14 +export function bindCustByOpenId(params) {
  15 + return request({
  16 + url: 'wxPublicUser/bindCustByOpenId',
  17 + method: 'post',
  18 + data: params
  19 + })
  20 +}
  21 +
  22 +
  23 +
  24 +
  25 +
  26 +
  27 +
  28 +
... ...
src/api/selfNav/selfNav.js 0 → 100644
  1 +import request from '@/utils/request'
  2 +
  3 +
  4 +// 获取OpenId
  5 +export function getOpenIdByCode(params) {
  6 + return request({
  7 + url: 'weixinPublicPay/getOpenIdByCode',
  8 + method: 'post',
  9 + data: params
  10 + })
  11 +}
  12 +
  13 +
  14 +// 获取token
  15 +export function getTokenByOpenId(params) {
  16 + return request({
  17 + url: 'wxPublicUser/getTokenByOpenId',
  18 + method: 'post',
  19 + data: params
  20 + })
  21 +}
  22 +
  23 +// 获取用户消息
  24 +export function queryUserInfo(params) {
  25 + return request({
  26 + url: 'user/queryUserInfo',
  27 + method: 'post',
  28 + data: params
  29 + })
  30 +}
  31 +
  32 +//获取手机号和头像
  33 +export function queryCustPersonBaseInfo(params) {
  34 + return request({
  35 + url: 'user/queryCustPersonBaseInfo',
  36 + method: 'post',
  37 + data: params
  38 + })
  39 +}
  40 +
  41 +//获取手机号和头像
  42 +export function logout(params) {
  43 + return request({
  44 + url: 'user/logout',
  45 + method: 'post',
  46 + data: params
  47 + })
  48 +}
  49 +
  50 +
  51 +
  52 +
  53 +
  54 +
  55 +
  56 +
  57 +
  58 +
  59 +
  60 +
  61 +
  62 +
... ...
src/main.js
... ... @@ -70,10 +70,11 @@ import {
70 70 TransferDom,
71 71 Confirm,
72 72 Toast,
73   - dateFormat
  73 + dateFormat,
  74 + Loading
74 75 }from 'vux'
75 76  
76   -
  77 +Vue.component('loading', Loading)
77 78 Vue.component('Toast', Toast)
78 79 Vue.component('Confirm', Confirm)
79 80 Vue.component('TransferDom', TransferDom)
... ... @@ -94,6 +95,8 @@ Vue.component('tabbar-item', TabbarItem);
94 95 Vue.component('tab', Tab);
95 96 Vue.component('tab-item', TabItem);
96 97  
  98 +import { LoadingPlugin } from 'vux'
  99 +Vue.use(LoadingPlugin)
97 100  
98 101 import { ToastPlugin } from 'vux'
99 102 Vue.use(ToastPlugin)
... ...
src/router/index.js
... ... @@ -110,19 +110,19 @@ export default new Router({
110 110 component: () => import("@/views/mySelf/selfNav.vue")
111 111 },
112 112 //
113   - // // ------------------------建议反馈
114   - // {
115   - // path: '/suggestionBack',
116   - // name: 'suggestionBack',
117   - // component: () => import("@/views/mySelf/feedback/suggestionBack.vue")
118   - // },
119   - //
120   - // // ------------------------停车记录
121   - // {
122   - // path: '/parkNotes',
123   - // name: 'parkNotes',
124   - // component: () => import("@/views/mySelf/parkNotes/parkNotes.vue")
125   - // },
  113 + // ------------------------建议反馈
  114 + {
  115 + path: '/suggestionBack',
  116 + name: 'suggestionBack',
  117 + component: () => import("@/views/mySelf/feedback/suggestionBack.vue")
  118 + },
  119 +
  120 + // ------------------------停车记录
  121 + {
  122 + path: '/parkNotes',
  123 + name: 'parkNotes',
  124 + component: () => import("@/views/mySelf/parkNotes/parkNotes.vue")
  125 + },
126 126 //
127 127 //
128 128 // ------------------------绑定手机
... ...
src/utils/utils.js
... ... @@ -203,7 +203,7 @@ export default {
203 203 deviceInfo: this.myDeviceInfo,
204 204 salt: salt,
205 205 sign_type: "md5",
206   - token: sessionStorage.getItem('urlToken'),
  206 + token: sessionStorage.getItem("wx_Token"),
207 207 orgId: this.myOrgId
208 208 };
209 209 return reqData;
... ...
src/views/binding/binDing.vue
... ... @@ -3,71 +3,155 @@
3 3  
4 4 <mt-field label="手机号" placeholder="请输入正确的手机号" type="tel" v-model="phone" :attr="{ maxlength: 13 }"></mt-field>
5 5  
6   - <mt-field label="验证码" v-model="codeText" :disabled="disabled">
7   - <div class="getCode" @click="getCode">{{timeNum}}</div>
  6 + <mt-field label="验证码" v-model="codeText">
  7 + <button class="getCode" @click="getCode" :disabled="disabled">{{btntxt}}
  8 + </button>
8 9 </mt-field>
9 10  
10 11 <div style="margin-top: 34px" class="leftRightPadding">
11   - <mt-button type="danger" size="large">绑定</mt-button>
  12 + <mt-button type="danger" size="large" @click.native="bindphone">绑定</mt-button>
12 13 </div>
13 14 </div>
14 15 </template>
15 16  
16 17 <script>
  18 +
  19 +import { sendverificode, bindCustByOpenId } from "@/api/binDing/binding";
  20 +import {
  21 + getTokenByOpenId
  22 +} from "@/api/selfNav/selfNav";
17 23 export default {
18   - name: 'binDing',
  24 + name: "binDing",
19 25 data() {
20 26 return {
21   - codeText: '',
22   - phone: '',
23   - timeText: '获取验证码',
  27 + codeText: "",
  28 + phone: "",
  29 + btntxt: "获取验证码",
24 30 time: 0,
25   - disabled:false
26   - }
  31 + disabled: false
  32 + };
27 33 },
28   - created(){
29   - this.timeNum = this.timeText
  34 + created() {
  35 + // this.timeNum = this.timeText
30 36 },
31 37 methods: {
32   - getCode: function () {
33   - var reg=11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
  38 + getCode: function() {
  39 + var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
34 40 //var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone;
35   - if(this.phone==''){
36   - this.$vux.toast.text('请输入手机号码', 'top')
37   - }else if(!reg.test(this.phone)){
38   - this.$vux.toast.text('手机格式不正确', 'top')
39   - }else{
40   - this.time=60;
41   - this.disabled=true;
  41 + if (this.phone == "") {
  42 + this.$vux.toast.text("请输入手机号码", "top");
  43 + } else if (!reg.test(this.phone)) {
  44 + this.$vux.toast.text("手机格式不正确", "top");
  45 + } else {
  46 + this.time = 60;
  47 + this.disabled = true;
42 48 this.timer();
43   - /*axios.post(url).then(
44   - res=>{
45   - this.phonedata=res.data;
46   - })*/
  49 + this.sendverificode();
47 50 }
48 51 },
  52 + sendverificode: function() {
  53 + let that = this;
  54 + let jsondata = {};
  55 + let obj = {
  56 + phone: this.phone
  57 + };
  58 + jsondata = Object.assign(obj, this.$utils.commonParams());
  59 + jsondata.sign = this.$utils.signObject(jsondata);
  60 + sendverificode(jsondata).then(response => {
  61 + console.log(response);
  62 + if (response.code == 0) {
  63 + this.$vux.toast.text("获取验证码成功", "top");
  64 + } else {
  65 + this.$vux.toast.text(response.message, "top");
  66 + }
  67 + });
  68 + },
49 69 timer() {
50 70 if (this.time > 0) {
51 71 this.time--;
52   - this.btntxt=this.time+"s后重新获取";
  72 + this.btntxt = this.time + "S后重新获取";
53 73 setTimeout(this.timer, 1000);
54   - } else{
55   - this.time=0;
56   - this.btntxt="获取验证码";
57   - this.disabled=false;
  74 + } else {
  75 + this.time = 0;
  76 + this.btntxt = "获取验证码";
  77 + this.disabled = false;
  78 + }
  79 + },
  80 + bindphone: function() {
  81 + //
  82 + var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
  83 + //var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone;
  84 + if (this.phone == "") {
  85 + this.$vux.toast.text("请输入手机号码", "top");
  86 + } else if (!reg.test(this.phone)) {
  87 + this.$vux.toast.text("手机格式不正确", "top");
  88 + } else {
  89 + if (this.codeText) {
  90 + let jsondata = {
  91 + phoneNum: this.phone,
  92 + verifyCode: this.codeText,
  93 + openid: sessionStorage.getItem("wx_openId"), // o0Moh6eQhTm5bZVqT6wjdSUsZonM
  94 + orgId: this.$utils.myOrgId
  95 + };
  96 + // jsondata = JSON.stringify(jsondata);
  97 + bindCustByOpenId(jsondata).then(data => {
  98 + console.log(data);
  99 + if (data.code == 0 || data.code == "0") {
  100 + this.$vux.toast.text("亲,您已绑定成功!", "top")
  101 + this.$router.push({
  102 + path:'selfNav'
  103 + })
  104 + } else if (data.code == 1017 || data.code == "1017") {
  105 + this.$vux.toast.text("已经绑定过", "top")
  106 + this.$router.push({
  107 + path:'selfNav'
  108 + })
  109 + } else {
  110 + this.$vux.toast.text("绑定失败,请重新绑定!", "top")
  111 + }
  112 + });
  113 + } else {
  114 + this.$vux.toast.text("亲!请输入验证码", "top")
  115 + }
58 116 }
59 117 },
  118 + // 获取token
  119 + getTokenByOpenId() {
  120 + let that = this
  121 + var jsondata = {
  122 + openid: sessionStorage.getItem("wx_openId"),
  123 + deviceInfo: this.$utils.myDeviceInfo
  124 + };
  125 + getTokenByOpenId(jsondata).then(data => {
  126 + console.log("执行获取token的接口 " + JSON.stringify(data));
  127 + if (data.code == 0) {
  128 + console.log("用户 token " + data.data.token);
  129 + let _token = data.data.token;
  130 + console.log('getTokenByOpenId获取到的'+_token)
  131 + sessionStorage.setItem("wx_Token", data.data.token);
  132 + sessionStorage.setItem("WXPhone", data.data.phoneNum);
  133 + this.$router.push({
  134 + path:'selfNav'
  135 + })
  136 + } else {
  137 + this.$vux.toast.text(data.message, "top");
  138 + }
  139 + this.$vux.loading.hide();
  140 + });
  141 + },
60 142 }
61   -}
  143 +};
62 144 </script>
63 145  
64 146 <style scoped lang="scss">
65 147 .getCode {
66   - width: 100px;
  148 + width: 120px;
67 149 height: 48px;
68 150 line-height: 48px;
69 151 background: #ef4f4f;
70 152 color: #fff;
71 153 text-align: center;
  154 + border: 0;
  155 + margin-right: -10px
72 156 }
73 157 </style>
... ...
src/views/eInvoice/eInvoiceWrap.vue
... ... @@ -37,8 +37,8 @@
37 37 export default {
38 38 name: "eInvoiceWrap",
39 39 mounted(){
40   - let _token = this.$route.query.token;
41   - sessionStorage.setItem('urlToken',_token)
  40 + // let _token = this.$route.query.token;
  41 + // sessionStorage.setItem('urlToken',_token)
42 42 }
43 43 };
44 44 </script>
... ...
src/views/mySelf/selfNav.vue
... ... @@ -2,34 +2,239 @@
2 2 <div>
3 3 <div class="person-bg">
4 4 <div class="person-ifo">
5   - <div class="person-pic"></div>
  5 + <div class="person-pic" :style="{backgroundImage:'url('+this.headPicUrl+')',backgroundSize:'100%'}"></div>
6 6 <ul class="person-con">
7   - <li>15911111111</li>
8   - <li>账户余额: <span>¥100.00</span></li>
9   - <li>我的卡券:<span>20张</span></li>
  7 + <li>昵称:{{ userPhone}}</li>
  8 + <li>账户余额: <span>¥{{(acctBalance/100).toFixed(2)}}</span></li>
  9 + <li>我的卡券:<span>{{ couponNum }}张</span></li>
10 10 </ul>
11 11 </div>
12 12 </div>
13 13  
14   - <mt-cell title="会员卡" is-link :to="{ name: 'Toast' }"></mt-cell>
  14 + <mt-cell is-link v-for="i in menuList" :title="i.name" @click.native="toMemu(i.path)" :key="i.name"></mt-cell>
15 15  
16   - <mt-cell title="车辆管理" is-link :to="{ name: 'Toast' }"></mt-cell>
  16 + <!--<mt-cell title="车辆管理" is-link></mt-cell>-->
17 17  
18   - <mt-cell title="停车记录" is-link :to="{ name: 'parkNotes' }"></mt-cell>
  18 + <!--<mt-cell title="停车记录" is-link></mt-cell>-->
19 19  
20   - <mt-cell title="建议反馈" is-link :to="{ name: 'suggestionBack' }"></mt-cell>
  20 + <!--<mt-cell title="建议反馈" is-link></mt-cell>-->
21 21  
22   - <div class="leftRightPadding" style="margin-top: 34px">
23   - <mt-button type="danger" size="large">退出账户</mt-button>
  22 + <div class="leftRightPadding" style="margin-top: 34px" v-show="loginShow">
  23 + <mt-button type="danger" size="large" @click="loginHandle">{{ loginTxt }}</mt-button>
24 24 </div>
25 25  
26 26 </div>
27 27 </template>
28 28  
29 29 <script>
  30 +
  31 +import {
  32 + getOpenIdByCode,
  33 + getTokenByOpenId,
  34 + queryUserInfo,
  35 + queryCustPersonBaseInfo,
  36 + logout
  37 +} from "@/api/selfNav/selfNav";
30 38 export default {
31   - name: 'selfNav'
32   -}
  39 + name: "selfNav",
  40 + data() {
  41 + return {
  42 + menuList: [
  43 + { name: "会员卡", path: "" },
  44 + { name: "车辆管理", path: "" },
  45 + { name: "发票管理", path: "eInvoiceWrap" },
  46 + { name: "停车记录", path: "parkNotes" },
  47 + { name: "建议反馈", path: "suggestionBack" }
  48 + ],
  49 + webAppCode: "",
  50 + couponNum: 0, // 卡券数量
  51 + acctBalance: 0, // 账户余额
  52 + userPhone: "--",// 账户手机号
  53 + headPicUrl: require("@/assets/images/mySelf/photoBG.png"),// 用户图像
  54 + loginTxt: "绑定手机", // 退出账户
  55 + loginShow:true
  56 + // headPicUrl:headPic
  57 + };
  58 + },
  59 + created() {
  60 + this.$vux.loading.show({
  61 + text: "数据加载中..."
  62 + });
  63 + if (this.$utils.clientBrowser() == "微信") {
  64 + this.webAppCode = this.getCode();
  65 + }
  66 + },
  67 + mounted() {
  68 + let that = this;
  69 + if(sessionStorage.getItem("wx_openId")){
  70 + this.getTokenByOpenId(sessionStorage.getItem("wx_openId"));
  71 + // this.getinfoself()
  72 + }else{
  73 + if (this.webAppCode) {
  74 + this.getopenid();
  75 + }
  76 + }
  77 +
  78 + },
  79 + methods: {
  80 + // 获取code
  81 + getCode() {
  82 + var appID = this.$utils.myVxAppId;
  83 + var code = this.getUrlParam("code");
  84 + var local = window.location.href;
  85 + if (code == null || code === "") {
  86 + 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";
  87 + } else {
  88 + return code;
  89 + }
  90 + },
  91 + getUrlParam(name) {
  92 + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  93 + var r = window.location.search.substr(1).match(reg);
  94 + if (r != null) return unescape(r[2]);
  95 + return null;
  96 + },
  97 + // 获取openid
  98 + getopenid() {
  99 + let jsondata = {
  100 + appId: this.$utils.myVxAppId,
  101 + code: this.webAppCode
  102 + };
  103 + getOpenIdByCode(jsondata).then(data => {
  104 + console.log(data);
  105 + if (data.code == "0") {
  106 + let openid = data.data;
  107 + sessionStorage.setItem("wx_openId", openid);
  108 + console.log("用户 openid " + openid);
  109 + this.getTokenByOpenId(openid);
  110 + }else{
  111 + this.$vux.toast.text(data.message, "top");
  112 + }
  113 + });
  114 + },
  115 + // 获取token
  116 + getTokenByOpenId(openid) {
  117 + let that = this
  118 + var jsondata = {
  119 + openid: openid,
  120 + deviceInfo: this.$utils.myDeviceInfo
  121 + };
  122 + getTokenByOpenId(jsondata).then(data => {
  123 + console.log("执行获取token的接口 " + JSON.stringify(data));
  124 + if (data.code == 0) {
  125 + console.log("用户 token " + data.data.token);
  126 + let _token = data.data.token;
  127 + console.log('getTokenByOpenId获取到的'+_token)
  128 + sessionStorage.setItem("wx_Token", data.data.token);
  129 + sessionStorage.setItem("WXPhone", data.data.phoneNum);
  130 + that.getinfoself(); //获取用户信息
  131 + } else {
  132 + this.$vux.toast.text(data.message, "top");
  133 + }
  134 + this.$vux.loading.hide();
  135 + });
  136 + },
  137 + //获取用户信息
  138 + getinfoself() {
  139 + // alert('token是:'+sessionStorage.getItem("wx_Token"))
  140 + let jsondata = this.$utils.commonParams();
  141 + console.log(jsondata)
  142 + jsondata.sign = this.$utils.signObject(jsondata);
  143 + queryUserInfo(jsondata).then(data => {
  144 + this.$vux.loading.hide();
  145 + console.log("获取用户信息 " + JSON.stringify(data));
  146 + if (data.code == "0") {
  147 + var datas = data.data;
  148 + this.couponNum = datas.couponNum;//卡券数量
  149 + var openAcctType = datas.openAcctType;//是否开通账户 1 开通 0 未开通
  150 + var msgPushState = datas.msgPushState;//是否开启消息推送 1 是 0否
  151 + // this.userPhone = datas.phone;//手机号
  152 + var carCount = datas.carCount;//绑定车牌数量
  153 + this.acctBalance = datas.acctBalance;//账户余额 单位:分
  154 + var orderCount = datas.orderCount;//停车记录
  155 + var pettyPayAmount = datas.pettyPayAmount;//小额免密支付金额
  156 + var acctScoreBalance = datas.acctScoreBalance;//积分账户余额 单位:个
  157 + var pettyPayState = datas.pettyPayState;//用户是否开启小额免密支付 1是 0否
  158 + var yjstatus = datas.openAcctDepositType;//是否交了押金
  159 + var yjjine = datas.acctDepositBalance;//Yjjine
  160 + var headPicUrl = "";//头像
  161 + var custNickname = "";//昵称
  162 + var phone = "";//昵称
  163 +
  164 + this.queryCustPersonBaseInfo(); //获取手机号和头像
  165 + } else {
  166 + this.$vux.toast.text(data.message, "top");
  167 + }
  168 + });
  169 + },
  170 + //获取手机号和头像
  171 + queryCustPersonBaseInfo() {
  172 + let jsondata = this.$utils.commonParams()
  173 + jsondata.sign = this.$utils.signObject(jsondata);
  174 + queryCustPersonBaseInfo(jsondata).then(data => {
  175 + // this.userPhone = datas.phone;//手机号
  176 + console.log('获取用户手机头像'+JSON.stringify(data))
  177 + if (data.code == "0") {
  178 + if(data.data.headPicUrl){
  179 + this.headPicUrl = data.data.headPicUrl;//头像
  180 + }else{
  181 + this.headPicUrl = require("@/assets/images/mySelf/photoBG.png");
  182 + }
  183 +
  184 + var custNickname = data.data.custNickname;//昵称
  185 + this.userPhone = data.data.userPhone;//昵称
  186 + // this.loginTxt = "退出登陆";
  187 + this.loginShow = false
  188 + } else {
  189 + this.$vux.toast.text(data.message, "top");
  190 + }
  191 + });
  192 + },
  193 + // 注册登陆或者退出登陆
  194 + loginHandle() {
  195 + if (this.loginTxt == "退出登陆") {
  196 + let jsondata = {};
  197 + let obj = {
  198 + token: sessionStorage.getItem("wx_Token")
  199 + };
  200 + jsondata = Object.assign(obj, this.$utils.commonParams());
  201 + jsondata.sign = this.$utils.signObject(jsondata);
  202 + logout(jsondata).then(data => {
  203 + console.log("执行获取token的接口 " + JSON.stringify(data));
  204 + if (data.code == 0) {
  205 + sessionStorage.setItem("wx_Token", null);
  206 + sessionStorage.setItem("WXPhone", null);
  207 + this.couponNum = 0; // 卡券数量
  208 + this.acctBalance = 0; // 账户余额
  209 + this.userPhone = "--";// 账户手机号
  210 + this.headPicUrl = require("@/assets/images/mySelf/photoBG.png");// 用户图像
  211 + this.loginTxt = "绑定手机"; // 退出账户
  212 + this.$router.push({
  213 + path: "binDing"
  214 + });
  215 + } else {
  216 + this.$vux.toast.text(data.message, "top");
  217 + }
  218 + });
  219 + } else {
  220 + this.$router.push({
  221 + path: "binDing"
  222 + });
  223 + }
  224 + },
  225 + // 前往各个子页面
  226 + toMemu(path) {
  227 + let _token = sessionStorage.getItem("wx_Token");
  228 + if (_token) {
  229 + this.$router.push({
  230 + path: path
  231 + });
  232 + } else {
  233 + this.$vux.toast.text("请先绑定手机号", "top");
  234 + }
  235 + }
  236 + }
  237 +};
33 238 </script>
34 239  
35 240 <style scoped lang="scss">
... ... @@ -44,21 +249,22 @@ export default {
44 249 padding-top: 45px;
45 250 display: flex;
46 251 color: #ffbfbf;
47   - .person-pic{
  252 + .person-pic {
48 253 width: 64px;
49 254 height: 64px;
50 255 margin-right: 15px;
51 256 background: url("../../assets/images/mySelf/photoBG.png") no-repeat;
52 257 }
53 258 }
54   - .person-con{
55   - span{
  259 +
  260 + .person-con {
  261 + span {
56 262 font-size: 16px;
57 263 font-weight: bold;
58 264 }
59 265 }
60 266  
61   - .mint-cell{
  267 + .mint-cell {
62 268 border-bottom: 1px solid #EFEDED;
63 269 }
64 270 </style>
... ...