bindWx.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="login-container">
  3. <view class="login-logo">
  4. <image src="../../static/login/wxlogin.png" alt=""></image>
  5. </view>
  6. <view class="login-form">
  7. <view class="" style="height: 30rpx;">
  8. </view>
  9. <button :class="['landing',checkIn ? 'landing_true' : 'landing_false']" :disabled="checkIn ? false : true"
  10. class="zai-btn" @tap="subReg">绑定</button>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import uniPopup from '../../components/uni-popup/uni-popup.vue';
  16. import uniPopupConfirm from '../../components/uni-popup/uni-popup-confirm.vue';
  17. import _get from "../../common/_get";
  18. import _data from "../../common/_data";
  19. export default {
  20. data() {
  21. return {
  22. miaoqiang: 'tests',
  23. popuMsg: '恭喜您注册成功,是否立即更改资料?',
  24. showPassword: true,
  25. showText: true,
  26. second: 60,
  27. form: {
  28. phone: '',
  29. password: '',
  30. code_coerce:1,
  31. sms_code: '',
  32. type: 'REGISTER'
  33. },
  34. close_icon: true
  35. }
  36. },
  37. components: {
  38. uniPopup,
  39. uniPopupConfirm
  40. },
  41. onLoad() {
  42. },
  43. onShow() {
  44. console.log(this.form.mobileCode);
  45. let _this = this;
  46. _get.getSysConfig({}, function(res) {
  47. // console.log('111111111111111111111',res.user_regiter_code_status)
  48. if (res.user_regiter_sms_status == 1) {
  49. _this.form.mobileCode = 1
  50. } else {
  51. _this.form.mobileCode = 0
  52. }
  53. if(res.user_regiter_code_status == 1){
  54. _this.form.code_coerce = 1
  55. }else {
  56. _this.form.code_coerce = 0
  57. }
  58. })
  59. },
  60. computed: {
  61. checkIn() {
  62. return true
  63. }
  64. },
  65. methods: {
  66. backLogin() {
  67. uni.navigateBack({
  68. })
  69. },
  70. goTerms() {
  71. uni.navigateTo({
  72. 'url': '/pages/in/terms'
  73. })
  74. },
  75. goPrivacy() {
  76. uni.navigateTo({
  77. 'url': '/pages/in/privacy'
  78. })
  79. },
  80. goPath() {
  81. uni.navigateTo({
  82. 'url': '/pages/in/web'
  83. })
  84. },
  85. close() {
  86. let _this = this;
  87. uni.reLaunch({
  88. url: '../chat/index',
  89. success: function() {
  90. _this.$refs.popup.close();
  91. }
  92. });
  93. },
  94. confirm(e) {
  95. let _this = this;
  96. uni.redirectTo({
  97. url: '/pages/my/details',
  98. success: function() {
  99. _this.$refs.popup.close();
  100. }
  101. });
  102. },
  103. isPoneAvailable($poneInput) {
  104. let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  105. if (!myreg.test($poneInput)) {
  106. return false;
  107. } else {
  108. return true;
  109. }
  110. },
  111. getCode() {
  112. let _this = this;
  113. if (this.form.phone.trim() == '') {
  114. uni.showToast({
  115. title: '请输入手机号',
  116. icon: 'none'
  117. });
  118. return false;
  119. }
  120. if (!this.isPoneAvailable(this.form.phone.trim())) {
  121. uni.showToast({
  122. title: '请输入正确的手机号',
  123. icon: 'none'
  124. });
  125. return false;
  126. }
  127. _get.getSms({
  128. mobile: this.form.phone,
  129. type: 'REGISTER'
  130. }, function(res) {
  131. console.log(22222)
  132. _this.cutDown();
  133. }, function(res) {
  134. console.log(1111)
  135. uni.showToast({
  136. title: res.msg,
  137. duration: 2000,
  138. icon: 'none'
  139. });
  140. })
  141. },
  142. cutDown(val) { //倒计时
  143. //获取验证码
  144. this.showText = false;
  145. var interval = setInterval(() => {
  146. let times = --this.second;
  147. times = times < 0 ? 0 : times;
  148. this.second = times < 10 ? '0' + times : times //小于10秒补 0
  149. }, 1000)
  150. setTimeout(() => {
  151. clearInterval(interval)
  152. this.second = 60;
  153. this.showText = true;
  154. }, 60000)
  155. },
  156. subReg() {
  157. let _this = this;
  158. uni.login({
  159. provider: 'weixin',
  160. success: function (loginRes) {
  161. console.log('loginRes.authResult',loginRes.authResult);
  162. // 获取用户信息
  163. uni.getUserInfo({
  164. provider: 'weixin',
  165. success: function (infoRes) {
  166. console.log('用户昵称为:' + JSON.stringify(infoRes.userInfo) );
  167. // console.log();
  168. _this.$httpSend({
  169. path: "/im/user/app_bangding",
  170. data: {
  171. openId: infoRes.userInfo.openId,
  172. nickName: infoRes.userInfo.nickName,
  173. gender: infoRes.userInfo.gender,
  174. unionId: infoRes.userInfo.unionId,
  175. avatarUrl: infoRes.userInfo.avatarUrl
  176. },
  177. success_action: true,
  178. success(res) {
  179. console.log(JSON.stringify(res.data));
  180. uni.showToast({
  181. title: '绑定成功',
  182. duration: 1000,
  183. });
  184. setTimeout(()=> {
  185. uni.switchTab({
  186. url:'/pages/my/index'
  187. });
  188. },1500)
  189. }
  190. });
  191. }
  192. });
  193. }
  194. })
  195. }
  196. }
  197. }
  198. </script>
  199. <style scoped lang="scss">
  200. .uni-input-placeholder {
  201. color: #ccc !important;
  202. }
  203. input[type="password"]::-ms-reveal {
  204. display: none;
  205. }
  206. .login-icon {
  207. image {
  208. width: 40rpx;
  209. height: 40rpx;
  210. }
  211. }
  212. .login-nav-bar {
  213. height: 44px;
  214. display: flex;
  215. align-items: center;
  216. position: absolute;
  217. justify-content: flex-start;
  218. left: 0;
  219. top: 0;
  220. /* #ifdef APP-PLUS */
  221. top: var(--status-bar-height);
  222. /* #endif */
  223. .arrow-back {
  224. width: 44rpx;
  225. height: 44rpx;
  226. margin-left: 20rpx;
  227. }
  228. }
  229. .login-container {
  230. background-color: #ffffff;
  231. height: 100vh;
  232. width: 100vw;
  233. padding: 0 60rpx;
  234. position: relative;
  235. box-sizing: border-box;
  236. // background-image: url(@/static/login/bg.png);
  237. background-repeat: no-repeat;
  238. background-size: 100% auto;
  239. .login-form {
  240. display: flex;
  241. flex-direction: column;
  242. .login-bottom {
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. height: 100rpx;
  247. .login-random {
  248. text-decoration: none;
  249. color: #999;
  250. font-size: 14px;
  251. }
  252. .tips {
  253. font-size: 12px;
  254. color: #b5746c;
  255. height: 60rpx;
  256. line-height: 60rpx;
  257. text-align: center;
  258. // width: 100%;
  259. }
  260. }
  261. .login-btn {
  262. width: 100%;
  263. height: 100rpx;
  264. border-radius: 50px;
  265. background-color: #2da2fd;
  266. color: #fff;
  267. font-size: 16px;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. margin-top: 100rpx;
  272. }
  273. .form-item {
  274. display: flex;
  275. height: 100rpx;
  276. align-items: center;
  277. border-bottom: 1px solid #eee;
  278. .item-lable {
  279. font-size: 16px;
  280. color: #333;
  281. width: 180rpx;
  282. }
  283. .item-input {
  284. border: none;
  285. outline: none;
  286. background: none;
  287. font-size: 16px;
  288. color: #000;
  289. height: 100%;
  290. flex: 1;
  291. }
  292. }
  293. }
  294. .login-title {
  295. padding-top: 250rpx;
  296. font-size: 24px;
  297. font-weight: bold;
  298. padding-bottom: 150rpx;
  299. }
  300. .login-logo{
  301. padding-top: 200rpx;
  302. padding-bottom: 80rpx;
  303. text-align: center;
  304. }
  305. .login-logo image{
  306. width: 150rpx;
  307. height: 150rpx;
  308. }
  309. }
  310. .zai-viewl {
  311. width: 100%;
  312. display: flex;
  313. justify-content: center;
  314. }
  315. .zai-box {
  316. padding: 0 100upx;
  317. position: relative;
  318. }
  319. .zai-logo {
  320. width: 160upx;
  321. width: 160upx;
  322. height: 160upx;
  323. margin-top: 114upx;
  324. }
  325. .zai-title {
  326. position: absolute;
  327. top: 0;
  328. line-height: 360upx;
  329. font-size: 68upx;
  330. color: #fff;
  331. text-align: center;
  332. width: 100%;
  333. margin-left: -100upx;
  334. }
  335. .zai-form {
  336. margin-top: 150upx;
  337. }
  338. .form-code {
  339. margin-top: 30upx;
  340. display: flex;
  341. justify-content: center;
  342. align-items: center;
  343. height: 100%;
  344. }
  345. .form-code .code {
  346. height: 100%;
  347. border-radius: 50px;
  348. text-align: center;
  349. font-size: 14px;
  350. background: #ff65a3;
  351. color: #ffffff;
  352. }
  353. .zai-input {
  354. background: #e2f5fc;
  355. margin-top: 30upx;
  356. border-radius: 100upx;
  357. padding: 20upx 40upx;
  358. font-size: 36upx;
  359. }
  360. .code-input {
  361. background: #e2f5fc;
  362. border-radius: 100upx;
  363. padding: 20upx 40upx;
  364. font-size: 36upx;
  365. width: 40%;
  366. }
  367. .input-placeholder,
  368. .zai-input {
  369. color: #94afce;
  370. }
  371. .zai-label {
  372. text-align: center;
  373. font-size: 30upx;
  374. color: #666;
  375. height: 120rpx;
  376. display: flex;
  377. align-items: center;
  378. text-align: left;
  379. }
  380. .zai-btn {
  381. background: #2da2fd;
  382. border: 0;
  383. border-radius: 50rpx;
  384. font-size: 16px;
  385. color: #fff;
  386. width: 100%;
  387. height: 100rpx;
  388. display: flex;
  389. align-items: center;
  390. justify-content: center;
  391. }
  392. .zai-btn:after {
  393. border: 0;
  394. }
  395. /*按钮点击效果*/
  396. .zai-btn.button-hover {
  397. transform: translate(1upx, 1upx);
  398. }
  399. .zai-footer {
  400. display: flex;
  401. justify-content: center;
  402. align-items: center;
  403. color: #a7b6d0;
  404. padding-top: 10px;
  405. }
  406. </style>