index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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="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. </ul>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import { RemindBox } from '~components/mobile/common'
  51. import BScroll from 'better-scroll'
  52. // 实现深拷贝
  53. function deepCopy(target) {
  54. if (typeof target !== 'object') return
  55. // 判断目标类型,来创建返回值
  56. var newObj = target instanceof Array ? [] : {}
  57. for (var item in target) {
  58. // 只复制元素自身的属性,不复制原型链上的
  59. if (target.hasOwnProperty(item)) {
  60. newObj[item] = typeof target[item] === 'object' ? deepCopy(target[item]) : target[item]
  61. }
  62. }
  63. return newObj
  64. }
  65. export default {
  66. name: 'wechatView',
  67. layout: 'mobileNoHeader',
  68. // middleware: 'authenticated',
  69. data() {
  70. return {
  71. collectResult: '',
  72. timeoutCount: 0,
  73. telerror: false,
  74. telphoneNum: '',
  75. passwordNum: ''
  76. }
  77. },
  78. mounted() {
  79. this.$nextTick(() => {
  80. let info = localStorage.getItem('USOFTMALLWECHATINFO')
  81. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', JSON.parse(info))
  82. if (this.BScroll) {
  83. this.BScroll.refresh()
  84. } else {
  85. this.BScroll = new BScroll(this.$refs.userContent, {
  86. click: true
  87. })
  88. }
  89. })
  90. },
  91. methods: {
  92. clickItem(item) {
  93. let userAccount = deepCopy(this.$store.state.option.wechatInfo.data.userAccount)
  94. userAccount.spaceUU = item.uu
  95. this.$http.get('/newLogin/other', {params: userAccount}).then(res => {
  96. this.$store.dispatch('loadUserInfo').then(() => {
  97. if (this.$route.query.url && this.$route.query.url !== '') {
  98. this.$router.replace(this.$route.query.url)
  99. } else {
  100. this.goLastPage()
  101. }
  102. })
  103. })
  104. },
  105. telphoneBlur() {
  106. this.telerror = false
  107. if (!/^1[3|5|7|8]\d{9}$/.test(this.telphoneNum)) {
  108. this.telerror = true
  109. }
  110. },
  111. login() {
  112. if (this.telerror === true) {
  113. return false
  114. }
  115. let openid = this.$store.state.option.wechatInfo.data.openid
  116. this.$http.post('/wx/bindUser', {userTel: this.telphoneNum, userPwd: this.passwordNum, openId: openid}).then(res => {
  117. this.$store.commit('option/REQUEST_WECHATINFO_STATUS_SUCCESS', res.data)
  118. localStorage.setItem('USOFTMALLWECHATINFO', JSON.stringify(res.data))
  119. })
  120. },
  121. resgiter() {
  122. this.$http.get('/register/page').then(response => {
  123. if (response.data) {
  124. window.location.href = response.data.content
  125. }
  126. })
  127. }
  128. },
  129. components: {
  130. RemindBox
  131. },
  132. computed: {
  133. userName() {
  134. // return ''
  135. return this.$store.state.option.wechatInfo.data.nickname
  136. },
  137. headerImg() {
  138. // return ''
  139. return this.$store.state.option.wechatInfo.data.headimgurl
  140. },
  141. wechatInfo() {
  142. return this.$store.state.option.wechatInfo.data
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .wechat-view {
  149. position: fixed;
  150. z-index: 999;
  151. width: 100%;
  152. left: 0;
  153. right: 0;
  154. top: 0;
  155. bottom: 0;
  156. background: #fff;
  157. .header-view {
  158. background: #376ef3;
  159. height: 4.26rem;
  160. width: 100%;
  161. position: relative;
  162. padding-top: 0.56rem;
  163. .hearder-kuang {
  164. background: rgba(0, 0, 0, 0.18);
  165. width: 1.86rem;
  166. height: 1.86rem;
  167. border-radius: 50%;
  168. margin: 0 auto;
  169. overflow: hidden;
  170. position: relative;
  171. .header-img {
  172. background: #fff;
  173. width: 1.6rem;
  174. height: 1.6rem;
  175. border-radius: 50%;
  176. overflow: hidden;
  177. text-align: center;
  178. position: absolute;
  179. left: 50%;
  180. top: 50%;
  181. transform: translate3d(-50%, -50%, 0);
  182. img {
  183. width: 1.6rem;
  184. height: 1.6rem;
  185. border-radius: 50%;
  186. vertical-align: center;
  187. }
  188. }
  189. }
  190. .header-name {
  191. font-size: 0.3rem;
  192. color: #fff;
  193. text-align: center;
  194. margin-top: 0.24rem;
  195. }
  196. .headerbg {
  197. position: absolute;
  198. width: 100%;
  199. height: 0.88rem;
  200. bottom: 0px;
  201. left: 0px;
  202. }
  203. }
  204. .middle-view {
  205. padding: 0 0.71rem;
  206. margin-top: 0.56rem;
  207. ul li {
  208. padding-bottom: 0.1rem;
  209. min-height: 0.4rem;
  210. &.info {
  211. color: #3872f4;
  212. font-size: 0.24rem;
  213. margin-left: 0.64rem;
  214. margin-top: 0.2rem;
  215. margin-bottom: 0.2rem;
  216. }
  217. input {
  218. margin-left: 0.34rem;
  219. color: #aaa;
  220. font-size: 0.3rem;
  221. height: 0.5rem;
  222. line-height: 0.5rem;
  223. border: 0;
  224. display: inline-block;
  225. vertical-align: top;
  226. }
  227. &.telphone {
  228. border-bottom: 1px solid #eee;
  229. &::before {
  230. background: url('/images/mobile/@2x/wechat/tel_icon.png');
  231. content: ' ';
  232. width: 0.28rem;
  233. height: 0.5rem;
  234. display: inline-block;
  235. background-size: 100% 100%;
  236. vertical-align: top;
  237. }
  238. input {
  239. margin-left: 0.4rem;
  240. }
  241. }
  242. &.password {
  243. border-bottom: 1px solid #eee;
  244. &::before {
  245. background: url('/images/mobile/@2x/wechat/pass_icon.png');
  246. content: ' ';
  247. width: 0.34rem;
  248. height: 0.42rem;
  249. display: inline-block;
  250. background-size: 100% 100%;
  251. vertical-align: top;
  252. }
  253. }
  254. }
  255. .loginBtn {
  256. width: 5.8rem;
  257. height: 0.9rem;
  258. line-height: 0.9rem;
  259. text-align: center;
  260. font-size: 0.3rem;
  261. color: #fff;
  262. background: #376ef3;
  263. border-radius: 5px;
  264. margin: 1.29rem auto 0;
  265. }
  266. .register {
  267. width: 5.8rem;
  268. text-align: left;
  269. font-size: 0.24rem;
  270. color: #999;
  271. margin: 0.25rem auto 0;
  272. span {
  273. color: #0076ff;
  274. font-size: 0.24rem;
  275. text-align: center;
  276. border: 1px solid #0076ff;
  277. border-radius: 5px;
  278. height:0.44rem;
  279. width: 1.48rem;
  280. margin-left: 0.2rem;
  281. }
  282. }
  283. .company {
  284. margin-top: 1.51rem;
  285. position: relative;
  286. text-align: center;
  287. img {
  288. width: 1.78rem;
  289. height: 0.39rem;
  290. margin-top: 0.24rem;
  291. }
  292. p {
  293. font-size: 0.21rem;
  294. color: #aaa;
  295. margin: 0.13rem 0 0 0;
  296. }
  297. a {
  298. margin-top: 0.12rem;
  299. font-size: 0.18rem;
  300. color: #bbb;
  301. }
  302. .hr {
  303. width: 1.62rem;
  304. height: 0.02rem;
  305. background: #e3e3e3;
  306. position: absolute;
  307. left: 0.3rem;
  308. top: 0.45rem;
  309. &.right {
  310. right: 0.3rem;
  311. left: auto;
  312. }
  313. }
  314. }
  315. }
  316. .listAlert {
  317. position: fixed;
  318. top: 0;
  319. left: 0;
  320. right: 0;
  321. bottom: 0;
  322. background: #fff;
  323. padding: 0 0.2rem;
  324. overflow: hidden;
  325. z-index: 10000;
  326. li {
  327. line-height: 0.98rem;
  328. height: 0.98rem;
  329. border-bottom: 1px solid #dedede;
  330. }
  331. }
  332. }
  333. </style>