index.vue 11 KB

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