bindwechat.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <text class="logo-text">您的微信尚未绑定机构账号,填写以下资料进行绑定后,您能通过微信快速登录。</text>
  5. </view>
  6. <view class="login-form clearfix">
  7. <view class="login-input">
  8. <input type="text"
  9. v-model="bindLinkName"
  10. maxlength="30"
  11. class="input"
  12. placeholder="请输入姓名"
  13. />
  14. </view>
  15. </view>
  16. <view class="login-form clearfix">
  17. <view class="login-input">
  18. <input type="number"
  19. v-model="bindLinkPhone"
  20. maxlength="11"
  21. class="input"
  22. placeholder="请输入手机号"
  23. />
  24. </view>
  25. </view>
  26. <view class="login-form clearfix">
  27. <view class="login-input code">
  28. <input type="number"
  29. v-model="imageCode"
  30. maxlength="6"
  31. class="input"
  32. placeholder="请输入右侧图形验证码"
  33. />
  34. </view>
  35. <view class="login-input img-btn">
  36. <view class="vscodeimg">
  37. <image :src="imageCodeUrl" mode=""></image>
  38. </view>
  39. <view class="vscod-refresh" @click.stop="getVerificationCode">
  40. <text class="iconfont icon-shuaxin"></text>
  41. <text class="ref-text">刷新</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="login-form clearfix">
  46. <view class="login-input code">
  47. <input type="number"
  48. v-model="mobildeCode"
  49. maxlength="6"
  50. class="input"
  51. placeholder="请输入短信验证码"
  52. />
  53. </view>
  54. <view class="login-input btn" :class="[isMobileDisabled ? 'disabled' : '']" @click.stop="getMobileCodeFn">
  55. <button type="button"
  56. :disabled="isMobileDisabled"
  57. class="input"
  58. >{{ mobileCodeText }}</button>
  59. </view>
  60. </view>
  61. <view class="login-form clearfix">
  62. <view class="login-btn" @click="bindWechatInfo">绑定</view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { mapMutations } from 'vuex';
  68. import authorize from '@/common/config/authorize.js'
  69. import { bindingWechat } from "@/api/use.js"
  70. import { getImageCode, getbindWechatCode } from "@/api/utils.js"
  71. var self;
  72. export default{
  73. data() {
  74. return{
  75. userID:'',
  76. bindMobile:'',
  77. bindLinkName:'', //用户姓名
  78. bindLinkPhone:'', //用户手机号
  79. mobildeCode:'', //手机验证码
  80. imageCode:'', //图形验证码
  81. imageCodeUrl:'', //图形验证码地址
  82. imageCodetoken:'', //图形校验token
  83. isMobileDisabled:false, //获取手机短信按钮
  84. count: '', //倒计时
  85. mobileCodeText: '获取验证码',
  86. codeTime: null,
  87. loginType:'', //跳转类型
  88. alertText:'',
  89. listType: '',
  90. listVal: '',
  91. detilType:'',
  92. id:''//商品ID
  93. }
  94. },
  95. onLoad(option) {
  96. console.log(option)
  97. this.codeType = option.codeType
  98. this.option = option
  99. this.loginType = option.type;
  100. this.id = option.id
  101. if(option.listType) {
  102. this.listType = option.listType;
  103. this.listVal = option.listVal;
  104. }
  105. this.getVerificationCode()
  106. },
  107. methods:{
  108. ...mapMutations(['login']),
  109. bindWechatInfo(){
  110. let params ={
  111. userID:this.userID,
  112. mobile:this.bindLinkPhone,
  113. linkName:this.bindLinkName,
  114. verificationCode:this.mobildeCode,
  115. }
  116. bindingWechat(params).then(res =>{
  117. console.log(res)
  118. }).catch(res =>{
  119. })
  120. },
  121. getVerificationCode(){//图形验证
  122. getImageCode().then(res => {
  123. this.imageCodeUrl = res.data.baseImage
  124. this.imageCodetoken = res.data.token
  125. })
  126. },
  127. getMobileCodeFn(){//获取手机验证码
  128. let params = {
  129. mobile:this.bindLinkPhone,
  130. mobileOrEmail:this.bindMobile,
  131. platformType:2,
  132. imgCode:this.imageCode,
  133. token:this.imageCodetoken,
  134. }
  135. getbindWechatCode(params).then(res =>{
  136. this.$util.msg('验证短信已发送',2000)
  137. const TIME_COUNT = 60;
  138.       if (!this.codeTime) {
  139.         this.count = TIME_COUNT;
  140.         this.isMobileDisabled = true;
  141.         this.codeTime = setInterval(() => {
  142.         if (this.count > 1 && this.count <= TIME_COUNT) {
  143.           this.count--
  144.           this.mobileCodeText = this.count +'s重新发送'
  145.          } else {
  146.           this.isMobileDisabled = false;
  147.           clearInterval(this.codeTime)
  148.           this.codeTime = null
  149. this.mobileCodeText = '获取验证码'
  150.          }
  151.         },1000)
  152.        }
  153. }).catch( res =>{
  154. this.$util.msg(res.msg,2000)
  155. })
  156. },
  157. goUserLogininit(){
  158. let url;
  159. if(this.loginType) {
  160. if(this.loginType=='detilType'){
  161. this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
  162. }else if(this.loginType=='search'){
  163. this.$api.redirectTo('/pages/search/search');
  164. }else if(this.loginType == 1){
  165. url ='/pages/tabBar/cart/cart'
  166. }else if(this.loginType == 2){
  167. url ='/pages/tabBar/user/user'
  168. }else {
  169. url ='/pages/tabBar/home/home'
  170. }
  171. uni.switchTab({
  172. url
  173. })
  174. } else if(this.listType) {
  175. this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
  176. }
  177. }
  178. },
  179. onShow() {
  180. this.$api.getStorage().then((resolve) => {
  181. console.log(resolve)
  182. this.userID = resolve.userID
  183. this.bindMobile = resolve.bindMobile
  184. })
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. .login{
  190. width: 100%;
  191. height: auto;
  192. border-top: 1px solid #F7F7F7;
  193. .model-warp.none{
  194. display: none;
  195. }
  196. .model-warp.show{
  197. display: block;
  198. }
  199. .login-main{
  200. width: 702rpx;
  201. background: rgba(225, 86, 22, 0.1);
  202. display: flex;
  203. flex-direction: column;
  204. align-items: center;
  205. height: 68rpx;
  206. padding: 20rpx 24rpx;
  207. margin: 24rpx 0 118rpx 0;
  208. .logo-text{
  209. font-size: 24rpx;
  210. line-height: 34rpx;
  211. color: $color-system;
  212. }
  213. }
  214. .login-form{
  215. width: 702rpx;
  216. height: auto;
  217. padding: 0 24rpx;
  218. .login-input{
  219. width: 654rpx;
  220. height: 40rpx;
  221. padding: 24rpx;
  222. margin-bottom: 20rpx;
  223. background: #F7F7F7;
  224. border-radius: 14rpx;
  225. display: flex;
  226. flex-direction: column;
  227. align-items: center;
  228. &.code{
  229. width: 370rpx;
  230. float: left;
  231. margin-right: 20rpx;
  232. }
  233. &.btn{
  234. width: 210rpx;
  235. float: left;
  236. background: $btn-confirm;
  237. .input{
  238. color: #FFFFFF;
  239. background: $btn-confirm;
  240. }
  241. &.disabled{
  242. background: #F7F7F7;
  243. .input{
  244. background: #F7F7F7;
  245. color: #999999;
  246. }
  247. }
  248. }
  249. &.img-btn{
  250. width: 250rpx;
  251. height: 88rpx;
  252. padding: 0;
  253. float: left;
  254. background: #FFFFFF;
  255. display: block;
  256. .vscodeimg{
  257. width: 180rpx;
  258. height: 88rpx;
  259. float: left;
  260. display: flex;
  261. flex-direction: column;
  262. align-items: center;
  263. border-radius: 14rpx;
  264. image{
  265. width: 180rpx;
  266. height: 88rpx;
  267. border-radius: 14rpx;
  268. }
  269. }
  270. .vscod-refresh{
  271. width: 70rpx;
  272. float: right;
  273. display: flex;
  274. flex-direction: column;
  275. align-items: center;
  276. .icon-shuaxin{
  277. font-size: 48rpx;
  278. color: #333333;
  279. }
  280. .ref-text{
  281. font-size: 24rpx;
  282. color: #333333;
  283. }
  284. }
  285. }
  286. .input{
  287. width: 100%;
  288. height: 100%;
  289. background: #F7F7F7;
  290. font-size: $font-size-28;
  291. line-height: 40rpx;
  292. color: #333333;
  293. border-radius: 14rpx;
  294. }
  295. }
  296. }
  297. .login-btn{
  298. width: 702rpx;
  299. height: 88rpx;
  300. border-radius: 14rpx;
  301. font-size: $font-size-28;
  302. line-height: 88rpx;
  303. color: #FFFFFF;
  304. margin: 0 auto;
  305. text-align: center;
  306. background: $btn-confirm;
  307. margin-top: 100rpx;
  308. }
  309. .model-authorization{
  310. width: 100%;
  311. height: 100%;
  312. position: fixed;
  313. top: 0;
  314. left: 0;
  315. z-index: 999;
  316. .authorization{
  317. width: 518rpx;
  318. height: 320rpx;
  319. position: absolute;
  320. background: rgba(255,255,255,.7);
  321. left: 0;
  322. right: 0;
  323. bottom: 0;
  324. top: 0;
  325. margin: auto;
  326. .to-btn{
  327. position: absolute;
  328. top: 0;
  329. left: 0;
  330. right: 0;
  331. bottom: 0;
  332. margin: auto;
  333. width: 70%;
  334. height: 88rpx;
  335. font-size: $font-size-28;
  336. line-height: 88rpx;
  337. color: #FFFFFF;
  338. text-align: center;
  339. border-radius: 44rpx;
  340. }
  341. }
  342. }
  343. }
  344. </style>