index.vue 8.8 KB

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