index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="reg" :style="{ 'height': setHeight + 'px' }">
  3. <view class="title">欢迎注册巴巴礼品网</view>
  4. <div class="form" v-if="step === 1">
  5. <form @submit="submit1" report-submit='true'>
  6. <view class="verify">
  7. <view class="list">
  8. <view class="item">
  9. <input type='number' placeholder='填写手机号码' placeholder-class='placeholder' v-model="phone"></input>
  10. </view>
  11. <view class="item acea-row row-between-wrapper">
  12. <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" v-model="yzm"></input>
  13. <button class="code font-color" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
  14. {{ text }}
  15. </button>
  16. </view>
  17. </view>
  18. <button form-type="submit" class="confirmBnt">立即注册</button>
  19. </view>
  20. </form>
  21. <view class="login">已有账号,<navigator hover-class="none" url="/pages/users/login/index">立即登录?</navigator></view>
  22. </div>
  23. <div class="form2" v-else>
  24. <view class='avatar acea-row row-center-wrapper row-column' @click='uploadpic'>
  25. <view v-if='avatar ==""'>
  26. <text class='iconfont icon-icon25201'></text>
  27. <view>上传图片</view>
  28. </view>
  29. <view v-else>
  30. <image :src="avatar"></image>
  31. </view>
  32. </view>
  33. <div class="item">
  34. <div class="acea-row row-middle">
  35. <input type="text" placeholder="请输入用户昵称" placeholder-class="placeholder" v-model="nickname" required />
  36. </div>
  37. </div>
  38. <div class="item">
  39. <div class="acea-row row-middle">
  40. <input type="password" placeholder="请输入密码" placeholder-class="placeholder" v-model="password" required />
  41. </div>
  42. </div>
  43. <div class="item">
  44. <div class="acea-row row-middle">
  45. <input type="password" placeholder="再次确认密码" placeholder-class="placeholder" v-model="qrPassword" required />
  46. </div>
  47. </div>
  48. <div class="item">
  49. <div class="acea-row row-middle">
  50. <input type="text" placeholder="请输入您的微信号" placeholder-class="placeholder" v-model="weixin_name" required />
  51. </div>
  52. </div>
  53. <button class="btn" @click="submit2">完成注册</button>
  54. <button class="back" @click="back">返回</button>
  55. <view class="login">已有账号,<navigator hover-class="none" url="/pages/users/login/index">立即登录?</navigator></view>
  56. </div>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. registerVerify,
  62. ApiReg1,
  63. ApiReg2
  64. } from '@/api/api.js';
  65. import CryptoJS from "@/libs/CryptoJS";
  66. import sendVerifyCode from "@/mixins/SendVerifyCode";
  67. const BACK_URL = "login_back_url";
  68. export default {
  69. mixins: [sendVerifyCode],
  70. data() {
  71. return {
  72. setHeight: 0,
  73. phone:'',
  74. yzm:'',
  75. step:1,
  76. token: '',
  77. avatar: '',
  78. nickname: '',
  79. password: '',
  80. qrPassword: '',
  81. weixin_name: '',
  82. tjUid: ''
  83. }
  84. },
  85. mounted() {
  86. let that = this
  87. uni.getSystemInfo({
  88. success: function (res) {
  89. that.setHeight = res.windowHeight
  90. }
  91. })
  92. },
  93. onLoad(options) {
  94. this.tjUid = options.uid || '';
  95. },
  96. methods: {
  97. async code() {
  98. let that = this;
  99. if (!that.phone) return that.$util.Tips({
  100. title: '请填写手机号码!'
  101. });
  102. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  103. title: '请输入正确的手机号码!'
  104. });
  105. var secret_key = "b1bd7a4b8da3e47ce58e73b9e5f656c4";
  106. var AES = new CryptoJS.AES(secret_key);
  107. await registerVerify({
  108. mobile: that.phone,
  109. token: AES.encrypt(that.phone),
  110. time: new Date().getTime()
  111. }).then(res => {
  112. that.$util.Tips({
  113. title: res.msg
  114. });
  115. that.sendCode();
  116. }).catch(err => {
  117. return that.$util.Tips({
  118. title: err
  119. });
  120. });
  121. },
  122. async submit1() {
  123. let that = this;
  124. if (!that.phone) return that.$util.Tips({
  125. title: '请填写手机号码'
  126. });
  127. if (!(/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.phone))) return that.$util.Tips({
  128. title: '请输入正确的手机号码'
  129. });
  130. if (!that.yzm) return that.$util.Tips({
  131. title: '请填写验证码'
  132. });
  133. if (!/^[\w\d]+$/i.test(that.yzm)) return that.$util.Tips({
  134. title: '请输入正确的验证码'
  135. });
  136. ApiReg1({
  137. mobile: that.phone,
  138. yzm: that.yzm
  139. }).then(res => {
  140. that.token = res.data.token;
  141. that.step = 2;
  142. }).catch(res => {
  143. that.$util.Tips({
  144. title: res
  145. });
  146. });
  147. },
  148. uploadpic: function () {
  149. let that = this;
  150. that.$util.uploadImageOne('upload/index', function (res) {
  151. that.avatar = res.data.img;
  152. });
  153. },
  154. submit2 () {
  155. let that = this;
  156. if (!that.nickname) return that.$util.Tips({
  157. title: '请输入用户昵称'
  158. });
  159. if (!that.password) return that.$util.Tips({
  160. title: '请输入密码'
  161. });
  162. if (that.password.length < 6) return that.$util.Tips({
  163. title: '密码不能少于6位'
  164. });
  165. if (!that.qrPassword) return that.$util.Tips({
  166. title: '请输入确认密码'
  167. });
  168. if (that.qrPassword !== that.password) return that.$util.Tips({
  169. title: '二次密码不相等'
  170. });
  171. if (!that.weixin_name) return that.$util.Tips({
  172. title: '请输入您的微信号'
  173. });
  174. ApiReg2({
  175. token: that.token,
  176. avatar: that.avatar,
  177. nickname: that.nickname,
  178. password: that.password,
  179. qrPassword: that.qrPassword,
  180. weixin_name: that.weixin_name,
  181. tjUid: that.tjUid
  182. }).then(res => {
  183. that.$store.commit("LOGIN", {
  184. 'token': res.data.token,
  185. 'time': 2592000
  186. });
  187. that.$store.commit("UPDATE_USERINFO", res.data.user_info);
  188. const backUrl = that.$Cache.get(BACK_URL) || "/pages/my/index";
  189. that.$Cache.clear(BACK_URL);
  190. }).catch(err => {
  191. that.$util.Tips({
  192. title: err
  193. });
  194. });
  195. },
  196. back(){
  197. this.step = 1;
  198. }
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. .reg{
  204. background: #fff;
  205. }
  206. .title{
  207. font-size: 42rpx;
  208. text-align: center;
  209. padding-top: 60rpx;
  210. }
  211. .verify .phone {
  212. font-size: 32rpx;
  213. font-weight: bold;
  214. text-align: center;
  215. margin-top: 55rpx;
  216. }
  217. .verify .list {
  218. width: 580rpx;
  219. margin: 53rpx auto 0 auto;
  220. }
  221. .verify .list .item {
  222. width: 100%;
  223. height: 110rpx;
  224. border-bottom: 2rpx solid #f0f0f0;
  225. }
  226. .verify .list .item input {
  227. width: 100%;
  228. height: 100%;
  229. font-size: 32rpx;
  230. }
  231. .verify .list .item .placeholder {
  232. color: #b9b9bc;
  233. }
  234. .verify .list .item input.codeIput {
  235. width: 340rpx;
  236. }
  237. .verify .list .item .code {
  238. font-size: 32rpx;
  239. background-color: #fff;
  240. }
  241. .verify .list .item .code.on {
  242. color: #b9b9bc !important;
  243. }
  244. .verify .confirmBnt {
  245. font-size: 32rpx;
  246. width: 580rpx;
  247. height: 90rpx;
  248. border-radius: 45rpx;
  249. color: #fff;
  250. margin: 92rpx auto 0 auto;
  251. text-align: center;
  252. line-height: 90rpx;
  253. background: #ff5c00;
  254. }
  255. .form .login{
  256. display: flex;
  257. justify-content: center;
  258. margin-top: 30rpx;
  259. navigator{
  260. color:#ff5c00;
  261. }
  262. }
  263. .form2{
  264. padding: 40rpx;
  265. .avatar{
  266. width:140rpx;
  267. height:140rpx;
  268. font-size:22rpx;
  269. color:#bbb;
  270. border:1rpx dashed #ddd;
  271. margin: 20rpx auto;
  272. text-align: center;
  273. .iconfont{
  274. font-size: 50rpx;
  275. }
  276. image{
  277. width:140rpx;
  278. height:140rpx;
  279. }
  280. }
  281. .item {
  282. border-bottom: 1rpx solid #ededed;
  283. padding: 45rpx 0 20rpx 0;
  284. image{
  285. width:40rpx;
  286. height:40rpx;
  287. margin-right: 20rpx;
  288. }
  289. input{
  290. flex-grow: 1;
  291. font-size: 28rpx;
  292. }
  293. .placeholder{
  294. color:#ccc;
  295. }
  296. }
  297. .btn {
  298. font-size: 32rpx;
  299. width: 580rpx;
  300. height: 85rpx;
  301. border-radius: 45rpx;
  302. color: #fff;
  303. margin: 80rpx auto 0 auto;
  304. text-align: center;
  305. line-height: 85rpx;
  306. background: #ff5c00;
  307. }
  308. .back{
  309. font-size: 32rpx;
  310. width: 580rpx;
  311. height: 85rpx;
  312. border-radius: 45rpx;
  313. margin: 20rpx auto 0 auto;
  314. text-align: center;
  315. line-height: 85rpx;
  316. border: 1rpx solid #dcdee2;
  317. color:#515a6e;
  318. }
  319. .login{
  320. display: flex;
  321. justify-content: center;
  322. margin-top: 30rpx;
  323. navigator{
  324. color:#ff5c00;
  325. }
  326. }
  327. }
  328. </style>