bind-operator.vue 9.0 KB

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