index.vue 10 KB

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