home.vue
4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<template>
<div class="home-page">
<ModalHaveTitle class="base-info" :title="'顾问基本信息'">
<BaseInfoList :list="serviceInfo"></BaseInfoList>
<NavButton :text="'复制活动链接'" @click-btn="copyLink" class="copy-link"></NavButton>
</ModalHaveTitle>
<div class="home-menu">
<span
v-for="(item, index) in homeMenu"
:key="index" class="menu-item"
:class="{actived: item.text === curMenu}"
@click="changeMenu(item.text)">{{item.text}}</span>
</div>
<OrderList v-if="curMenu === '订单信息'" :uid="userUid"></OrderList>
<Exchange v-if="curMenu === '退换货'" :uid="userUid"></Exchange>
<Coupon v-if="curMenu === '优惠券'"></Coupon>
<UserInfo v-if="curMenu === '用户信息'" :wechatUid="serviceInfo.wechatUid.value" :userCode="userCode" @get-user-uid="getUserUid"></UserInfo>
<Tip :text="tipCont" :hasClose="tipClose" :show="tipShow" @change-tip-status="changeTipStatus"></Tip>
</div>
</template>
<script>
import BaseInfoList from './components/base-info-list';
import OrderList from './components/order-list';
import Exchange from './components/exchange';
import Coupon from './components/coupon';
import UserInfo from './components/user-info';
import NavButton from './components/nav-button';
import ModalHaveTitle from './components/modal-have-title';
import Tip from './components/tip';
import Clipboard from 'clipboard';
import homeModel from '../../models/home';
export default {
name: 'Home',
data() {
return {
homeMenu: [
{text: '用户信息'},
{text: '订单信息'},
{text: '退换货'},
{text: '优惠券'}
],
curMenu: '用户信息',
serviceInfo: {
wechatCode: {label: '微信号', value: ''},
wechatNickName: {label: '微信昵称', value: ''},
wechatMobile: {label: '微信手机号', value: ''},
machineCode: {label: '机器码', value: ''},
yohoMobile: {label: '有货账号', value: ''},
wechatUid: {label: '有货UID', value: ''},
groupName: {label: '所属分组', value: ''},
staffName: {label: '运营人员', value: ''}
},
tipCont: '复制成功',
tipShow: false,
tipClose: false,
wechatCode: this.queryString().operator,
userCode: this.queryString().friend,
shareCode: '',
userUid: ''
};
},
mounted() {
homeModel.getWechatConsultant({wechatCode: this.wechatCode}).then(ret => {
if (ret && ret.code === 200) {
let data = ret.data || {};
Object.keys(data).forEach((item, key) => {
this.serviceInfo[item].value = data[item];
});
this.getWechatShareCode(data.wechatUid || '');
}
});
},
methods: {
queryString() {
let vars = [], hash;
let hashes = window.location.search.slice(1).split('&');
for (let i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getWechatShareCode(wechatUid) {
wechatUid = 500031262;
homeModel.getWechatShareCode({
uid: wechatUid
}).then(ret => {
console.log(ret)
});
},
changeMenu(item) {
this.curMenu = item;
},
copyLink() {
let that = this;
let clipboard = new Clipboard('.copy-link', {
text: function() {
return this.shareCode;
}
});
clipboard.on('success', function(e) {
that.copyDialog();
e.clearSelection();
});
clipboard.on('error', function() {
that.copyErrDialog();
});
},
copyDialog() {
this.tipShow = true;
},
copyErrDialog() {
this.tipShow = true;
this.tipCont = '复制失败,请手动复制"XXXX"';
this.tipClose = true;
},
changeTipStatus(item) {
this.tipShow = item;
},
getUserUid(uid) {
console.log(uid)
this.userUid = uid;
}
},
components: {
BaseInfoList,
OrderList,
Exchange,
Coupon,
UserInfo,
NavButton,
ModalHaveTitle,
Tip
}
};
</script>
<style lang="scss">
html, body {
width: 100%;
margin: 0;
padding: 0;
font-size: 12px;
background: #f6f6f6;
font-family: helvetica,Arial,"\9ED1\4F53",sans-serif;
}
* {
-webkit-tap-highlight-color: transparent;
}
a {
color: #000;
text-decoration: none;
}
ul, li {
list-style: none;
margin: 0;
padding: 0;
}
.red {
color: #d8021a;
}
.home-page {
max-width: 794px;
width: 100%;
margin: 0 auto;
}
.base-info {
.copy-link-btn {
width: 100%;
margin: 0 auto;
background: #000;
color: #fff;
text-align: center;
border: none;
outline: none;
margin: 0 auto;
display: block;
height: 24px;
line-height: 24px;
border-radius: 5px;
}
.info-list {
height: auto;
overflow: hidden;
li {
width: 50%;
float: left;
height: 24px;
line-height: 24px;
}
}
}
.home-menu {
display: flex;
justify-content: space-evenly;
margin-top: 20px;
background: #fff;
height: 61px;
line-height: 52px;
border-bottom: 1px solid #EAEBEB;
box-sizing: border-box;
.menu-item {
padding: 5px;
border-radius: 5px;
font-family: PingFang-SC-Regular;
font-size: 16px;
cursor: pointer;
color: #979797;
&.actived {
color: #000;
font-family: PingFang-SC-Medium;
}
}
}
</style>