index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <div class="wechat-view">
  3. <div class="header-view">
  4. <div class="hearder-kuang">
  5. <div class="header-img">
  6. <img src="/images/mobile/@2x/wechat/header-img.png" :src="headerImg"/>
  7. </div>
  8. </div>
  9. <div class="header-name">
  10. {{userName}}
  11. </div>
  12. <img src="/images/mobile/@2x/wechat/headerbg.png" class="headerbg"/>
  13. </div>
  14. <div class="middle-view">
  15. <ul>
  16. <li class="telphone">
  17. <input placeholder="请输入手机号" type="tel" maxlength="11" @blur="telphoneBlur" v-model="telphoneNum"/>
  18. </li>
  19. <li class="wechat-view-info">
  20. <div v-show="telerror">
  21. 请输入正确的手机号码
  22. </div>
  23. </li>
  24. <li class="password">
  25. <input placeholder="请输入密码" type="password" v-model="passwordNum"/>
  26. </li>
  27. </ul>
  28. <div class="loginBtn" @click="login">确定绑定已有账号登录</div>
  29. <div class="register">还没有优软账号,直接<span @click="resgiter">创建新账号</span></div>
  30. <nuxt-link :to="'/'" class="mobile_footer company" tag="div">
  31. <div class="hr"></div>
  32. <img src="/images/mobile/@2x/wechat/logo.png" alt="">
  33. <div class="hr right"></div>
  34. <!--<p>此页面由深圳市优软商城科技有限公司提供</p>-->
  35. <!--<nuxt-link :to="'/'">www.usoftmall.com</nuxt-link>-->
  36. <!-- <a href="https://www.usoftmall.com">www.usoftmall.com</a> -->
  37. </nuxt-link>
  38. </div>
  39. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  40. <div class="listAlert" ref="userContent" v-show="wechatInfo.enterprises">
  41. <ul>
  42. <li v-for="(item, index) in wechatInfo.enterprises" @click="clickItem(item)">
  43. {{item.enName}}
  44. </li>
  45. <li @click="clickItem({uu: 0})">
  46. <a>个人账户</a>
  47. </li>
  48. </ul>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. import { RemindBox } from '~components/mobile/common'
  54. import BScroll from 'better-scroll'
  55. export default {
  56. name: 'wechatView',
  57. layout: 'mobileNoHeader',
  58. // middleware: 'authenticated',
  59. data() {
  60. return {
  61. collectResult: '',
  62. timeoutCount: 0,
  63. telerror: false,
  64. telphoneNum: '',
  65. passwordNum: ''
  66. }
  67. },
  68. mounted() {
  69. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  70. if (this.$route.query.url) {
  71. localStorage.setItem('RETURNURL', this.$route.query.url || '')
  72. }
  73. if (!info && !this.$route.query.code) {
  74. window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb3274b676737a319&redirect_uri=https://www.usoftmall.com/mobile/wechat&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  75. } else if (info) {
  76. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
  77. } else {
  78. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  79. }
  80. this.$nextTick(() => {
  81. if (this.BScroll) {
  82. this.BScroll.refresh()
  83. } else {
  84. this.BScroll = new BScroll(this.$refs.userContent, {
  85. click: true
  86. })
  87. }
  88. })
  89. },
  90. methods: {
  91. clickItem(item) {
  92. let userAccount = this.baseUtils.deepCopy(this.$store.state.option.wechatInfo.data.userAccount)
  93. userAccount.spaceUU = item.uu
  94. this.$http.get('/newLogin/other', {params: userAccount}).then(res => {
  95. this.$store.dispatch('loadUserInfo').then(() => {
  96. let _url = localStorage.getItem('RETURNURL')
  97. if (_url !== '') {
  98. localStorage.removeItem('RETURNURL')
  99. this.$router.replace(_url)
  100. } else if (this.$route.query.url && this.$route.query.url !== '') {
  101. this.$router.replace(this.$route.query.url)
  102. } else {
  103. this.goLastPage()
  104. }
  105. })
  106. })
  107. },
  108. telphoneBlur() {
  109. this.telerror = false
  110. if (!/^1[3|5|7|8]\d{9}$/.test(this.telphoneNum)) {
  111. this.telerror = true
  112. }
  113. },
  114. login() {
  115. if (this.telerror === true) {
  116. return false
  117. }
  118. if (!this.passwordNum || this.passwordNum === '') {
  119. this.collectResult = '密码不能为空'
  120. this.timeoutCount++
  121. return false
  122. }
  123. let openid = this.$store.state.option.wechatInfo.data.openid
  124. this.$http.post('/wx/bindUser', {userTel: this.telphoneNum, userPwd: this.passwordNum, openId: openid}).then(res => {
  125. if (res.data.success) {
  126. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', res.data)
  127. localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(res.data))
  128. } else {
  129. this.collectResult = res.data.message
  130. this.timeoutCount++
  131. }
  132. }, err => {
  133. this.collectResult = err.response.data || '绑定失败'
  134. this.timeoutCount++
  135. })
  136. },
  137. resgiter() {
  138. this.$http.get('/register/page').then(response => {
  139. if (response.data) {
  140. window.location.href = response.data.content
  141. }
  142. })
  143. }
  144. },
  145. components: {
  146. RemindBox
  147. },
  148. computed: {
  149. userName() {
  150. // return ''
  151. return this.wechatInfo.nickname
  152. },
  153. headerImg() {
  154. // return ''
  155. return this.wechatInfo.headimgurl
  156. },
  157. wechatInfo() {
  158. return this.$store.state.option.wechatInfo.data
  159. }
  160. }
  161. }
  162. </script>
  163. <style scoped lang="scss">
  164. .wechat-view {
  165. position: fixed;
  166. z-index: 999;
  167. width: 100%;
  168. left: 0;
  169. right: 0;
  170. top: 0;
  171. bottom: 0;
  172. background: #fff;
  173. .header-view {
  174. background: #376ef3;
  175. height: 4.26rem;
  176. width: 100%;
  177. position: relative;
  178. padding-top: 0.56rem;
  179. .hearder-kuang {
  180. background: rgba(0, 0, 0, 0.18);
  181. width: 1.86rem;
  182. height: 1.86rem;
  183. border-radius: 50%;
  184. margin: 0 auto;
  185. overflow: hidden;
  186. position: relative;
  187. .header-img {
  188. background: #fff;
  189. width: 1.6rem;
  190. height: 1.6rem;
  191. border-radius: 50%;
  192. overflow: hidden;
  193. text-align: center;
  194. position: absolute;
  195. left: 50%;
  196. top: 50%;
  197. margin: -0.8rem 0 0 -0.8rem;
  198. img {
  199. width: 1.6rem;
  200. height: 1.6rem;
  201. border-radius: 50%;
  202. vertical-align: center;
  203. }
  204. }
  205. }
  206. .header-name {
  207. font-size: 0.3rem;
  208. color: #fff;
  209. text-align: center;
  210. margin-top: 0.24rem;
  211. }
  212. .headerbg {
  213. position: absolute;
  214. width: 100%;
  215. height: 0.88rem;
  216. bottom: 0px;
  217. left: 0px;
  218. }
  219. }
  220. .middle-view {
  221. padding: 0 0.71rem;
  222. margin-top: 0.56rem;
  223. ul li {
  224. padding-bottom: 0.1rem;
  225. min-height: 0.4rem;
  226. &.wechat-view-info {
  227. color: #3872f4;
  228. font-size: 0.24rem;
  229. margin-left: 0.64rem;
  230. margin-top: 0.2rem;
  231. margin-bottom: 0.2rem;
  232. }
  233. input {
  234. margin-left: 0.34rem;
  235. color: #aaa;
  236. font-size: 0.3rem;
  237. height: 0.5rem;
  238. line-height: 0.5rem;
  239. border: 0;
  240. display: inline-block;
  241. vertical-align: top;
  242. }
  243. &.telphone {
  244. border-bottom: 1px solid #eee;
  245. &::before {
  246. background: url('/images/mobile/@2x/wechat/tel_icon.png');
  247. content: ' ';
  248. width: 0.28rem;
  249. height: 0.5rem;
  250. display: inline-block;
  251. background-size: 100% 100%;
  252. vertical-align: top;
  253. }
  254. input {
  255. margin-left: 0.4rem;
  256. }
  257. }
  258. &.password {
  259. border-bottom: 1px solid #eee;
  260. &::before {
  261. background: url('/images/mobile/@2x/wechat/pass_icon.png');
  262. content: ' ';
  263. width: 0.34rem;
  264. height: 0.42rem;
  265. display: inline-block;
  266. background-size: 100% 100%;
  267. vertical-align: top;
  268. }
  269. }
  270. }
  271. .loginBtn {
  272. width: 5.8rem;
  273. height: 0.9rem;
  274. line-height: 0.9rem;
  275. text-align: center;
  276. font-size: 0.3rem;
  277. color: #fff;
  278. background: #376ef3;
  279. border-radius: 5px;
  280. margin: 1.29rem auto 0;
  281. }
  282. .register {
  283. width: 5.8rem;
  284. text-align: left;
  285. font-size: 0.24rem;
  286. color: #999;
  287. margin: 0.25rem auto 0;
  288. span {
  289. color: #0076ff;
  290. font-size: 0.24rem;
  291. text-align: center;
  292. border: 1px solid #0076ff;
  293. border-radius: 5px;
  294. height:0.44rem;
  295. width: 1.48rem;
  296. margin-left: 0.2rem;
  297. }
  298. }
  299. .company {
  300. margin-top: 1.51rem;
  301. position: relative;
  302. text-align: center;
  303. img {
  304. width: 1.78rem;
  305. height: 0.39rem;
  306. margin-top: 0.24rem;
  307. }
  308. p {
  309. font-size: 0.21rem;
  310. color: #aaa;
  311. margin: 0.13rem 0 0 0;
  312. }
  313. a {
  314. margin-top: 0.12rem;
  315. font-size: 0.18rem;
  316. color: #bbb;
  317. }
  318. .hr {
  319. width: 1.62rem;
  320. height: 0.02rem;
  321. background: #e3e3e3;
  322. position: absolute;
  323. left: 0.3rem;
  324. top: 0.45rem;
  325. &.right {
  326. right: 0.3rem;
  327. left: auto;
  328. }
  329. }
  330. }
  331. }
  332. .listAlert {
  333. position: fixed;
  334. top: 0;
  335. left: 0;
  336. right: 0;
  337. bottom: 0;
  338. background: #fff;
  339. padding: 0 0.2rem;
  340. overflow: hidden;
  341. z-index: 10000;
  342. li {
  343. line-height: 0.98rem;
  344. height: 0.98rem;
  345. border-bottom: 1px solid #dedede;
  346. }
  347. }
  348. }
  349. </style>