bindwechat.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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="number"
  9. v-model="bindLinkName"
  10. maxlength="30"
  11. class="input"
  12. @blur="onBlurInput"
  13. placeholder="请输入姓名"
  14. />
  15. </view>
  16. </view>
  17. <view class="login-form clearfix">
  18. <view class="login-input">
  19. <input type="number"
  20. v-model="bindLinkPhone"
  21. maxlength="30"
  22. class="input"
  23. @blur="onBlurInput"
  24. placeholder="请输入手机号"
  25. />
  26. </view>
  27. </view>
  28. <view class="login-form clearfix">
  29. <view class="login-input code">
  30. <input type="number"
  31. v-model="bindGraphiCode"
  32. maxlength="4"
  33. class="input"
  34. placeholder="请输入右侧图形验证码"
  35. />
  36. </view>
  37. <view class="login-input img-btn">
  38. <view class="vscodeimg">
  39. <image src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2158189919,2752757953&fm=26&gp=0.jpg" mode=""></image>
  40. </view>
  41. <view class="vscod-refresh">
  42. <text class="iconfont icon-shuaxin"></text>
  43. <text class="ref-text">刷新</text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="login-form clearfix">
  48. <view class="login-input code">
  49. <input type="number"
  50. v-model="bindPhoneCode"
  51. maxlength="6"
  52. class="input"
  53. placeholder="请输入短信验证码"
  54. />
  55. </view>
  56. <view class="login-input btn" :class="[isDisabled === true ? 'disabled' : 'none']">
  57. <button type="button"
  58. @click.stop="getEmailCode" :disabled="isDisabled"
  59. class="input"
  60. >获取验证码</button>
  61. </view>
  62. </view>
  63. <view class="login-form clearfix">
  64. <view class="login-btn" @click="goLogin">绑定</view>
  65. </view>
  66. <view v-if="isToast" class="model-warp" >
  67. <view class="model-alert clearfix">
  68. <view class="alert-content">
  69. <view class="t-h1">{{toestText}}</view>
  70. <view class="t-p">请联系客服获取{{alertText}}后再登录,联系电话{{telPhone}}</view>
  71. </view>
  72. <view class="alert-btn">
  73. <view class="btn btn-confirm" @click="hideToast">确定</view>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- 授权按钮 -->
  78. <view class="model-warp" :class="[isUserInfo===false ? 'none':'show']">
  79. <view class="model-alert">
  80. <view class="alert-content">
  81. <view class="t-p">采美采购商城需要获取您的微信授权才能正常提供服务</view>
  82. </view>
  83. <view class="alert-btn">
  84. <view class="btn btn-cancel" @click="hideModel">取消</view>
  85. <button type="primary" size="small" open-type="getUserInfo" lang="zh_CN" @getuserinfo="getuserinfo" class="btn btn-confirm">授权</button>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import { mapMutations } from 'vuex';
  93. import authorize from '@/common/config/authorize.js'
  94. var self;
  95. export default{
  96. data() {
  97. return{
  98. bindLinkName:'', //用户姓名
  99. bindLinkPhone:'', //用户手机号
  100. bindGraphiCode:'', //图形验证
  101. bindPhoneCode:'', //手机验证码
  102. isDisabled:true, //获取验证码按钮
  103. isToast:false, //控制显示未输入邀请码提示
  104. isUserInfo:false, //控制显示授权弹窗
  105. nickName:'', //存储用户名
  106. userInfo:'', //存储微信用户授权信息
  107. isSuccess:false,
  108. toestText:'',
  109. telPhone:'',
  110. loginType:'', //跳转类型
  111. alertText:'',
  112. listType: '',
  113. listVal: '',
  114. detilType:'',
  115. id:''//商品ID
  116. }
  117. },
  118. onLoad(option) {
  119. console.log(option)
  120. },
  121. methods:{
  122. ...mapMutations(['login']),
  123. goLogin() {
  124. self.$api.get('/login/isEnabled',{userOrganizeID:self.userOrganizeID,invitationCode:self.invitationCode}, res => {
  125. if (res.code == "1") {
  126. //查看此微信用户是否已经授权过
  127. authorize.getSetting().then(res =>{
  128. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  129. if(res == 2){
  130. self.isUserInfo = true
  131. }else{
  132. self.isUserInfo = false
  133. self.wxGetUserInfo()
  134. }
  135. })
  136. }else if(res.code =='0'){
  137. self.toestText ='请输入邀请码';
  138. self.alertText ='邀请码';
  139. self.telPhone = res.msg;
  140. self.isToast = true;
  141. }else if(res.code =='-2'){
  142. self.toestText ='邀请码已失效';
  143. self.alertText ='新邀请码';
  144. self.telPhone = res.msg;
  145. self.isToast = true;
  146. }else if(res.code =='-3'){
  147. self.toestText ='邀请码已被使用';
  148. self.alertText ='新邀请码';
  149. self.telPhone = res.msg;
  150. self.isToast = true;
  151. }else{
  152. uni.showToast({icon:'none', title: res.msg, duration: 3000});
  153. self.isUserInfo = false
  154. }
  155. })
  156. },
  157. onBlurInput(e){//邮箱输入框失去焦点设置按钮
  158. if(e.detail.value ===''){
  159. this.isDisabled = true
  160. }else{
  161. this.isDisabled = false
  162. }
  163. },
  164. getEmailCode(){
  165. this.isDisabled = true
  166. },
  167. //关闭未填邀请码弹窗
  168. hideToast(){
  169. self.isToast = false;
  170. },
  171. //关闭未授权用户授权提示弹窗
  172. hideModel(){
  173. self.isUserInfo = false;
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss">
  179. .login{
  180. width: 100%;
  181. height: auto;
  182. border-top: 1px solid #F7F7F7;
  183. .model-warp.none{
  184. display: none;
  185. }
  186. .model-warp.show{
  187. display: block;
  188. }
  189. .login-main{
  190. width: 702rpx;
  191. background: rgba(225, 86, 22, 0.1);
  192. display: flex;
  193. flex-direction: column;
  194. align-items: center;
  195. height: 68rpx;
  196. padding: 20rpx 24rpx;
  197. margin: 24rpx 0 118rpx 0;
  198. .logo-text{
  199. font-size: 24rpx;
  200. line-height: 34rpx;
  201. color: $color-system;
  202. }
  203. }
  204. .login-form{
  205. width: 702rpx;
  206. height: auto;
  207. padding: 0 24rpx;
  208. .login-input{
  209. width: 654rpx;
  210. height: 40rpx;
  211. padding: 24rpx;
  212. margin-bottom: 20rpx;
  213. background: #F7F7F7;
  214. border-radius: 14rpx;
  215. display: flex;
  216. flex-direction: column;
  217. align-items: center;
  218. &.code{
  219. width: 370rpx;
  220. float: left;
  221. margin-right: 20rpx;
  222. }
  223. &.btn{
  224. width: 210rpx;
  225. float: left;
  226. &.none{
  227. background: $color-system;
  228. .input{
  229. color: #FFFFFF;
  230. background: $color-system;
  231. }
  232. }
  233. &.disabled{
  234. .input{
  235. color: #999999;
  236. }
  237. }
  238. }
  239. &.img-btn{
  240. width: 250rpx;
  241. height: 88rpx;
  242. padding: 0;
  243. float: left;
  244. background: #FFFFFF;
  245. display: block;
  246. .vscodeimg{
  247. width: 180rpx;
  248. height: 88rpx;
  249. float: left;
  250. display: flex;
  251. flex-direction: column;
  252. align-items: center;
  253. border-radius: 14rpx;
  254. image{
  255. width: 180rpx;
  256. height: 88rpx;
  257. border-radius: 14rpx;
  258. }
  259. }
  260. .vscod-refresh{
  261. width: 70rpx;
  262. float: right;
  263. display: flex;
  264. flex-direction: column;
  265. align-items: center;
  266. .icon-shuaxin{
  267. font-size: 48rpx;
  268. color: #333333;
  269. }
  270. .ref-text{
  271. font-size: 24rpx;
  272. color: #333333;
  273. }
  274. }
  275. }
  276. .input{
  277. width: 100%;
  278. height: 100%;
  279. background: #F7F7F7;
  280. font-size: $font-size-28;
  281. line-height: 40rpx;
  282. color: #333333;
  283. border-radius: 14rpx;
  284. }
  285. }
  286. }
  287. .login-btn{
  288. width: 702rpx;
  289. height: 88rpx;
  290. border-radius: 14rpx;
  291. font-size: $font-size-28;
  292. line-height: 88rpx;
  293. color: #FFFFFF;
  294. margin: 0 auto;
  295. text-align: center;
  296. background: $btn-confirm;
  297. margin-top: 100rpx;
  298. }
  299. .model-authorization{
  300. width: 100%;
  301. height: 100%;
  302. position: fixed;
  303. top: 0;
  304. left: 0;
  305. z-index: 999;
  306. .authorization{
  307. width: 518rpx;
  308. height: 320rpx;
  309. position: absolute;
  310. background: rgba(255,255,255,.7);
  311. left: 0;
  312. right: 0;
  313. bottom: 0;
  314. top: 0;
  315. margin: auto;
  316. .to-btn{
  317. position: absolute;
  318. top: 0;
  319. left: 0;
  320. right: 0;
  321. bottom: 0;
  322. margin: auto;
  323. width: 70%;
  324. height: 88rpx;
  325. font-size: $font-size-28;
  326. line-height: 88rpx;
  327. color: #FFFFFF;
  328. text-align: center;
  329. border-radius: 44rpx;
  330. }
  331. }
  332. }
  333. }
  334. </style>