bind-operator.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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="text"
  29. v-model="imageCode"
  30. maxlength="4"
  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' : '']" >
  55. <button type="button"
  56. @click.stop="getMobileCodeFn"
  57. :disabled="isMobileDisabled"
  58. class="input">
  59. {{ mobileCodeText }}
  60. </button>
  61. </view>
  62. </view>
  63. <view class="login-form clearfix">
  64. <view class="login-btn" @click="bindWechatInfo">绑定</view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import { mapState,mapMutations } from 'vuex'
  70. import authorize from '@/common/config/authorize.js'
  71. import wxLogin from "@/common/config/wxLogin.js"
  72. import { getbindOperatorCode } from "@/api/utils.js"
  73. export default{
  74. data() {
  75. return{
  76. shopOrderId:'',
  77. userID:'',
  78. bindLinkName:'', //供应商联系人姓名
  79. bindLinkPhone:'', //用户手机号
  80. mobildeCode:'', //手机验证码
  81. imageCode:'', //图形验证码
  82. imageCodeUrl:'', //图形验证码地址
  83. imageCodetoken:'', //图形校验token
  84. isMobileDisabled:false, //获取手机短信按钮
  85. count: '', //倒计时
  86. mobileCodeText: '获取验证码',
  87. codeTime: null,
  88. bind_supplierInfo:{}
  89. }
  90. },
  91. onLoad(option) {
  92. this.shopOrderId = option.shopOrderId
  93. // console.log(this.shopOrderId);
  94. this.bind_supplierInfo = uni.getStorageSync('bind_supplierInfo');
  95. this.getVerificationCode()
  96. },
  97. methods:{
  98. ...mapMutations(['login']),
  99. bindWechatInfo(){
  100. if( this.bindLinkName == ''){
  101. this.$util.msg('请输入姓名',2000)
  102. return
  103. }
  104. if( this.bindLinkPhone == ''){
  105. this.$util.msg('请输入手机号',2000)
  106. return
  107. }
  108. if(!this.$reg.isMobile(this.bindLinkPhone)){
  109. this.$util.msg('请输入正确的手机号',2000)
  110. return
  111. }
  112. if( this.mobildeCode == ''){
  113. this.$util.msg('请输入手机验证码',2000)
  114. return
  115. }
  116. if(!this.$reg.isMobileCode(this.mobildeCode)){
  117. this.$util.msg('验证码格式不正确',2000)
  118. return
  119. }
  120. this.bindingWechatLogin()
  121. },
  122. getVerificationCode(){//图形验证
  123. this.PublicService.GetImgVerifyCode().then(res => {
  124. this.imageCodeUrl = res.data.baseImage
  125. this.imageCodetoken = res.data.token
  126. })
  127. },
  128. getMobileCodeFn(){//获取手机验证码
  129. if( this.bindLinkPhone == ''){
  130. this.$util.msg('请输入手机号',2000);
  131. return
  132. }
  133. if(!this.$reg.isMobile(this.bindLinkPhone)){
  134. this.$util.msg('请输入正确的手机号',2000);
  135. return
  136. }
  137. if( this.imageCode == ''){
  138. this.$util.msg('请输入图形验证码',2000);
  139. return
  140. }
  141. let params = {
  142. userId:this.bind_supplierInfo.userId,
  143. mobile:this.bindLinkPhone,
  144. platformType:2,
  145. imgCode:this.imageCode,
  146. token:this.imageCodetoken,
  147. }
  148. this.isMobileDisabled = true;
  149. getbindOperatorCode(params).then(res =>{
  150. const TIME_COUNT = 60;
  151. this.$util.msg('验证短信已发送',2000)
  152.       if (!this.codeTime) {
  153.         this.count = TIME_COUNT;
  154. this.isMobileDisabled = true;
  155.         this.codeTime = setInterval(() => {
  156.         if (this.count > 1 && this.count <= TIME_COUNT) {
  157.           this.count--
  158.           this.mobileCodeText = this.count +'s重新发送'
  159.          } else {
  160.           this.isMobileDisabled = false;
  161.           clearInterval(this.codeTime)
  162.           this.codeTime = null
  163. this.mobileCodeText = '获取验证码'
  164.          }
  165.         },1000)
  166.        }
  167. }).catch( error =>{
  168. this.$util.msg(error.msg,2000)
  169. this.isMobileDisabled = false;
  170. })
  171. },
  172. bindingWechatLogin(){//获取用户基本信息登录
  173. wx.getUserInfo({
  174. success: res => {
  175. this.isUserInfo = false;
  176. this.userInfo = res.userInfo;
  177. let params ={
  178. userID:this.bind_supplierInfo.userId,
  179. mobile:this.bindLinkPhone,
  180. linkName:this.bindLinkName,
  181. verificationCode:this.mobildeCode,
  182. nickName:res.userInfo.nickName,
  183. headimgurl:res.userInfo.avatarUrl,
  184. openid:this.bind_supplierInfo.openid,
  185. shopID:this.bind_supplierInfo.shopId,
  186. unionId:this.bind_supplierInfo.unionId
  187. }
  188. this.ShopService.BindShopOperator(params).then(response =>{
  189. this.$api.navigateTo(`/supplier/pages/order/order-details?shopOrderId=${this.shopOrderId}`)
  190. }).catch(error =>{
  191. this.$util.msg(error.msg,2000)
  192. })
  193. }
  194. })
  195. },
  196. //关闭未授权用户授权提示弹窗
  197. hideModel(){
  198. this.isUserInfo = false;
  199. }
  200. },
  201. onShow() {
  202. }
  203. }
  204. </script>
  205. <style lang="scss">
  206. .login{
  207. width: 100%;
  208. height: auto;
  209. border-top: 1px solid #F7F7F7;
  210. .model-warp.none{
  211. display: none;
  212. }
  213. .model-warp.show{
  214. display: block;
  215. }
  216. .login-main{
  217. width: 702rpx;
  218. background: rgba(225, 86, 22, 0.1);
  219. display: flex;
  220. flex-direction: column;
  221. align-items: center;
  222. height: 68rpx;
  223. padding: 20rpx 24rpx;
  224. margin: 24rpx 0 118rpx 0;
  225. .logo-text{
  226. font-size: 24rpx;
  227. line-height: 34rpx;
  228. color: $color-system;
  229. }
  230. }
  231. .login-form{
  232. width: 702rpx;
  233. height: auto;
  234. padding: 0 24rpx;
  235. .login-input{
  236. width: 654rpx;
  237. height: 40rpx;
  238. padding: 24rpx;
  239. margin-bottom: 20rpx;
  240. background: #F7F7F7;
  241. border-radius: 14rpx;
  242. display: flex;
  243. flex-direction: column;
  244. align-items: center;
  245. &.code{
  246. width: 370rpx;
  247. float: left;
  248. margin-right: 20rpx;
  249. }
  250. &.btn{
  251. width: 258rpx;
  252. height: 88rpx;
  253. padding: 0;
  254. float: left;
  255. background: $btn-confirm;
  256. .input{
  257. width: 258rpx;
  258. height: 88rpx;
  259. line-height: 88rpx;
  260. padding: 0;
  261. border-radius: 14rpx;
  262. color: #FFFFFF;
  263. background: $btn-confirm;
  264. }
  265. &.disabled{
  266. background: #F7F7F7;
  267. .input{
  268. background: #F7F7F7;
  269. color: #999999;
  270. }
  271. }
  272. }
  273. &.img-btn{
  274. width: 250rpx;
  275. height: 88rpx;
  276. padding: 0;
  277. float: left;
  278. background: #FFFFFF;
  279. display: block;
  280. .vscodeimg{
  281. width: 180rpx;
  282. height: 88rpx;
  283. float: left;
  284. display: flex;
  285. flex-direction: column;
  286. align-items: center;
  287. border-radius: 14rpx;
  288. image{
  289. width: 180rpx;
  290. height: 88rpx;
  291. border-radius: 14rpx;
  292. }
  293. }
  294. .vscod-refresh{
  295. width: 70rpx;
  296. float: right;
  297. display: flex;
  298. flex-direction: column;
  299. align-items: center;
  300. .icon-shuaxin{
  301. font-size: 48rpx;
  302. color: #333333;
  303. }
  304. .ref-text{
  305. font-size: 24rpx;
  306. color: #333333;
  307. }
  308. }
  309. }
  310. .input{
  311. width: 100%;
  312. height: 100%;
  313. background: #F7F7F7;
  314. font-size: $font-size-28;
  315. line-height: 40rpx;
  316. color: #333333;
  317. border-radius: 14rpx;
  318. }
  319. }
  320. }
  321. .login-btn{
  322. width: 702rpx;
  323. height: 88rpx;
  324. border-radius: 14rpx;
  325. font-size: $font-size-28;
  326. line-height: 88rpx;
  327. color: #FFFFFF;
  328. margin: 0 auto;
  329. text-align: center;
  330. background: $btn-confirm;
  331. margin-top: 100rpx;
  332. }
  333. .model-authorization{
  334. width: 100%;
  335. height: 100%;
  336. position: fixed;
  337. top: 0;
  338. left: 0;
  339. z-index: 999;
  340. .authorization{
  341. width: 518rpx;
  342. height: 320rpx;
  343. position: absolute;
  344. background: rgba(255,255,255,.7);
  345. left: 0;
  346. right: 0;
  347. bottom: 0;
  348. top: 0;
  349. margin: auto;
  350. .to-btn{
  351. position: absolute;
  352. top: 0;
  353. left: 0;
  354. right: 0;
  355. bottom: 0;
  356. margin: auto;
  357. width: 70%;
  358. height: 88rpx;
  359. font-size: $font-size-28;
  360. line-height: 88rpx;
  361. color: #FFFFFF;
  362. text-align: center;
  363. border-radius: 44rpx;
  364. }
  365. }
  366. }
  367. }
  368. </style>