index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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. // 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`
  76. } else if (info) {
  77. info = JSON.parse(info)
  78. if (info.status === 1) {
  79. this.$store.dispatch('GerWechatInfo', {code: '', openId: info.openid})
  80. }
  81. } else {
  82. this.$store.dispatch('GerWechatInfo', {code: this.$route.query.code})
  83. }
  84. this.$nextTick(() => {
  85. if (this.BScroll) {
  86. this.BScroll.refresh()
  87. } else {
  88. this.BScroll = new BScroll(this.$refs.userContent, {
  89. click: true
  90. })
  91. }
  92. })
  93. },
  94. methods: {
  95. clickItem(item) {
  96. let userAccount = this.baseUtils.deepCopy(this.$store.state.option.wechatInfo.data.userAccount)
  97. userAccount.spaceUU = item.uu
  98. this.$http.get('/newLogin/other', {params: userAccount}).then(res => {
  99. this.$store.dispatch('loadUserInfo').then(() => {
  100. let _url = localStorage.getItem('RETURNURL')
  101. if (_url !== '') {
  102. localStorage.removeItem('RETURNURL')
  103. this.$router.replace(_url)
  104. } else if (this.$route.query.url && this.$route.query.url !== '') {
  105. this.$router.replace(this.$route.query.url)
  106. } else {
  107. this.goLastPage()
  108. }
  109. })
  110. })
  111. },
  112. telphoneBlur() {
  113. this.telerror = false
  114. if (!/^1[3|5|7|8]\d{9}$/.test(this.telphoneNum)) {
  115. this.telerror = true
  116. }
  117. },
  118. login() {
  119. if (this.telerror === true) {
  120. return false
  121. }
  122. if (!this.passwordNum || this.passwordNum === '') {
  123. this.collectResult = '密码不能为空'
  124. this.timeoutCount++
  125. return false
  126. }
  127. let openid = this.$store.state.option.wechatInfo.data.openid
  128. this.$http.post('/wx/bindUser', {userTel: this.telphoneNum, userPwd: this.passwordNum, openId: openid}).then(res => {
  129. if (res.data.success) {
  130. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', res.data)
  131. localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(res.data))
  132. } else {
  133. localStorage.removeItem('USOFTMALLWECHATINFO')
  134. this.collectResult = res.data.message
  135. this.timeoutCount++
  136. }
  137. }, err => {
  138. localStorage.removeItem('USOFTMALLWECHATINFO')
  139. this.collectResult = err.response.data || '绑定失败'
  140. this.timeoutCount++
  141. })
  142. },
  143. resgiter() {
  144. this.$http.get('/register/page').then(response => {
  145. if (response.data) {
  146. window.location.href = response.data.content
  147. }
  148. })
  149. }
  150. },
  151. components: {
  152. RemindBox
  153. },
  154. computed: {
  155. userName() {
  156. // return ''
  157. return this.wechatInfo.nickname
  158. },
  159. headerImg() {
  160. // return ''
  161. return this.wechatInfo.headimgurl
  162. },
  163. wechatInfo() {
  164. return this.$store.state.option.wechatInfo.data
  165. }
  166. }
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .wechat-view {
  171. position: fixed;
  172. z-index: 999;
  173. width: 100%;
  174. left: 0;
  175. right: 0;
  176. top: 0;
  177. bottom: 0;
  178. background: #fff;
  179. .header-view {
  180. background: #376ef3;
  181. height: 4.26rem;
  182. width: 100%;
  183. position: relative;
  184. padding-top: 0.56rem;
  185. .hearder-kuang {
  186. background: rgba(0, 0, 0, 0.18);
  187. width: 1.86rem;
  188. height: 1.86rem;
  189. border-radius: 50%;
  190. margin: 0 auto;
  191. overflow: hidden;
  192. position: relative;
  193. .header-img {
  194. background: #fff;
  195. width: 1.6rem;
  196. height: 1.6rem;
  197. border-radius: 50%;
  198. overflow: hidden;
  199. text-align: center;
  200. position: absolute;
  201. left: 50%;
  202. top: 50%;
  203. margin: -0.8rem 0 0 -0.8rem;
  204. img {
  205. width: 1.6rem;
  206. height: 1.6rem;
  207. border-radius: 50%;
  208. vertical-align: center;
  209. }
  210. }
  211. }
  212. .header-name {
  213. font-size: 0.3rem;
  214. color: #fff;
  215. text-align: center;
  216. margin-top: 0.24rem;
  217. }
  218. .headerbg {
  219. position: absolute;
  220. width: 100%;
  221. height: 0.88rem;
  222. bottom: 0px;
  223. left: 0px;
  224. }
  225. }
  226. .middle-view {
  227. padding: 0 0.71rem;
  228. margin-top: 0.56rem;
  229. ul li {
  230. padding-bottom: 0.1rem;
  231. min-height: 0.4rem;
  232. &.wechat-view-info {
  233. color: #3872f4;
  234. font-size: 0.24rem;
  235. margin-left: 0.64rem;
  236. margin-top: 0.2rem;
  237. margin-bottom: 0.2rem;
  238. }
  239. input {
  240. margin-left: 0.34rem;
  241. color: #aaa;
  242. font-size: 0.3rem;
  243. height: 0.5rem;
  244. line-height: 0.5rem;
  245. border: 0;
  246. display: inline-block;
  247. vertical-align: top;
  248. }
  249. &.telphone {
  250. border-bottom: 1px solid #eee;
  251. &::before {
  252. background: url('/images/mobile/@2x/wechat/tel_icon.png');
  253. content: ' ';
  254. width: 0.28rem;
  255. height: 0.5rem;
  256. display: inline-block;
  257. background-size: 100% 100%;
  258. vertical-align: top;
  259. }
  260. input {
  261. margin-left: 0.4rem;
  262. }
  263. }
  264. &.password {
  265. border-bottom: 1px solid #eee;
  266. &::before {
  267. background: url('/images/mobile/@2x/wechat/pass_icon.png');
  268. content: ' ';
  269. width: 0.34rem;
  270. height: 0.42rem;
  271. display: inline-block;
  272. background-size: 100% 100%;
  273. vertical-align: top;
  274. }
  275. }
  276. }
  277. .loginBtn {
  278. width: 5.8rem;
  279. height: 0.9rem;
  280. line-height: 0.9rem;
  281. text-align: center;
  282. font-size: 0.3rem;
  283. color: #fff;
  284. background: #376ef3;
  285. border-radius: 5px;
  286. margin: 1.29rem auto 0;
  287. }
  288. .register {
  289. width: 5.8rem;
  290. text-align: left;
  291. font-size: 0.24rem;
  292. color: #999;
  293. margin: 0.25rem auto 0;
  294. span {
  295. color: #0076ff;
  296. font-size: 0.24rem;
  297. text-align: center;
  298. border: 1px solid #0076ff;
  299. border-radius: 5px;
  300. height:0.44rem;
  301. width: 1.48rem;
  302. margin-left: 0.2rem;
  303. }
  304. }
  305. .company {
  306. margin-top: 1.51rem;
  307. position: relative;
  308. text-align: center;
  309. img {
  310. width: 1.78rem;
  311. height: 0.39rem;
  312. margin-top: 0.24rem;
  313. }
  314. p {
  315. font-size: 0.21rem;
  316. color: #aaa;
  317. margin: 0.13rem 0 0 0;
  318. }
  319. a {
  320. margin-top: 0.12rem;
  321. font-size: 0.18rem;
  322. color: #bbb;
  323. }
  324. .hr {
  325. width: 1.62rem;
  326. height: 0.02rem;
  327. background: #e3e3e3;
  328. position: absolute;
  329. left: 0.3rem;
  330. top: 0.45rem;
  331. &.right {
  332. right: 0.3rem;
  333. left: auto;
  334. }
  335. }
  336. }
  337. }
  338. .listAlert {
  339. position: fixed;
  340. top: 0;
  341. left: 0;
  342. right: 0;
  343. bottom: 0;
  344. background: #fff;
  345. padding: 0 0.2rem;
  346. overflow: hidden;
  347. z-index: 10000;
  348. li {
  349. line-height: 0.98rem;
  350. height: 0.98rem;
  351. border-bottom: 1px solid #dedede;
  352. }
  353. }
  354. }
  355. </style>