register.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="container">
  3. <view class="container_text" >
  4. <image class="banner-img" src="/static/img/logo.png" mode="scaleToFill"></image>
  5. </view>
  6. <view class="loginTitle"><text>注册</text></view>
  7. <view class="login_text">
  8. <view class="login_input flex">
  9. <view class="login_img"><image src="/static/icon/phone.png"></image></view>
  10. <view class="login_name"><input class="uni-input" type="text" v-model="phone" focus placeholder="请输入账号" /></view>
  11. </view>
  12. <view class="login_input flex">
  13. <view class="login_img"><image src="/static/icon/pread.png"></image></view>
  14. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入接点人id" /></view>
  15. </view>
  16. <view class="login_input flex">
  17. <view class="login_img"><image src="/static/icon/psw.png"></image></view>
  18. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
  19. </view>
  20. <view class="login_input flex">
  21. <view class="login_img"><image src="/static/icon/psw.png"></image></view>
  22. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  23. </view>
  24. <view class="login_input flex">
  25. <view class="login_img"><image src="/static/icon/code.png"></image></view>
  26. <view class="login_name flex">
  27. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  28. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  29. </view>
  30. </view>
  31. <view class="login_input flex">
  32. <view class="login_img"><image src="/static/icon/dw.png"></image></view>
  33. <picker @change="bindParentArea" :value="parent_area" :range="parent_areas" class="uni-input">
  34. <view class="placeholder" v-if="parent_area === ''">请选择区域</view>
  35. <text>{{ parent_area }}</text>
  36. </picker>
  37. </view>
  38. <view class="login_input flex">
  39. <view class="login_img"><image src="/static/icon/dw.png"></image></view>
  40. <picker @change="bindPayType" :value="pay_type" :range="pay_types" class="uni-input">
  41. <view class="placeholder" v-if="pay_type === ''">请选择支付方式</view>
  42. <text>{{ pay_type }}</text>
  43. </picker>
  44. </view>
  45. <view class="login_input flex">
  46. <view class="login_img"><image src="/static/icon/jft.png"></image></view>
  47. <view class="uni-input" style="color: #999;">
  48. 是否使用积分抵扣
  49. <image src="../../static/icon/noselect.png" mode="" v-if="!isSelsect" @click="jfdk(1)"></image>
  50. <image src="../../static/icon/select.png" mode="" v-if="isSelsect" @click="jfdk(0)"></image>
  51. </view>
  52. </view>
  53. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import { register, verify } from '@/api/login.js';
  59. export default {
  60. data() {
  61. return {
  62. phone: '', //用户
  63. password: '', //密码
  64. repassword: '',
  65. invitation: '', //接点人id
  66. code: '', //验证码
  67. time: '', //保存倒计时对象
  68. countDown: 0 ,//倒计时
  69. parent_area: '',//区域
  70. parent_areas: ['A','B','C'],//区域列表
  71. pay_type: '',
  72. pay_types: ['微信','余额','佣金'],
  73. isSelsect: false,
  74. };
  75. },
  76. onLoad() {
  77. // 获取扫码邀请人id
  78. this.invitation = uni.getStorageSync('spread')||'';
  79. },
  80. watch: {
  81. // 监听倒计时
  82. countDown(i) {
  83. if (i == 0) {
  84. clearInterval(this.time);
  85. }
  86. }
  87. },
  88. methods: {
  89. //选择是否积分抵扣
  90. jfdk(index) {
  91. if(index == 1) {
  92. this.isSelsect = true
  93. }else {
  94. this.isSelsect = false
  95. }
  96. },
  97. //选择区域
  98. bindParentArea(e) {
  99. console.log(e.detail.value)
  100. this.parent_area = this.parent_areas[e.detail.value]
  101. },
  102. //选择值支付方式
  103. bindPayType(e) {
  104. console.log(e)
  105. if(e.detail.value) {
  106. this.pay_type = this.pay_types[e.detail.value]
  107. }else if(e.detail.value == 0){
  108. this.pay_type = this.pay_types[e.detail.value]
  109. }
  110. },
  111. // 注册
  112. register() {
  113. let obj = this;
  114. if (obj.phone == '') {
  115. obj.$api.msg('请输入账号');
  116. return;
  117. }
  118. if (obj.password == '') {
  119. obj.$api.msg('请输入密码');
  120. return;
  121. }
  122. if (obj.repassword == '') {
  123. obj.$api.msg('请再次输入密码');
  124. return;
  125. }
  126. if (obj.repassword != obj.password) {
  127. obj.$api.msg('两次密码不正确');
  128. return;
  129. }
  130. if(obj.code == '') {
  131. obj.$api.msg('请输入验证吗');
  132. return;
  133. }
  134. if(obj.parent_area == '') {
  135. obj.$api.msg('请选择区域');
  136. return;
  137. }
  138. if(obj.pay_type == '') {
  139. obj.$api.msg('请选择支付方式');
  140. return;
  141. }
  142. let paytype = ''
  143. if(obj.pay_type == '微信') {
  144. paytype = 'weixin'
  145. }else if(obj.pay_type == '余额') {
  146. paytype = 'yue'
  147. }else if(obj.pay_type == '佣金') {
  148. paytype = 'brokerage'
  149. }
  150. register({
  151. account: obj.phone, //账号
  152. captcha: obj.code, //验证码
  153. password: obj.password ,//密码
  154. parent: obj.invitation,//接点人uid
  155. parent_area: obj.parent_area,//区域
  156. pay_type: paytype,
  157. use_integral: obj.isSelsect ? '1':'0',
  158. from: 'APP'
  159. }).then(function(e) {
  160. uni.showToast({
  161. title:'注册成功',
  162. duration:2000,
  163. position:'top'
  164. });
  165. setTimeout(function () {
  166. uni.navigateTo({
  167. url: '/pages/user/user'
  168. });
  169. },1000)
  170. }).catch( err => {
  171. console.log(err)
  172. })
  173. },
  174. //发送验证码
  175. verification() {
  176. let obj = this;
  177. if (this.phone == '') {
  178. this.$api.msg('请输入电话号码');
  179. return;
  180. }
  181. if (this.phone.length < 11) {
  182. this.$api.msg('请输入正确的手机号');
  183. return;
  184. }
  185. // 判断是否在倒计时
  186. if (obj.countDown > 0) {
  187. return false;
  188. } else {
  189. obj.countDown = 60;
  190. obj.time = setInterval(() => {
  191. obj.countDown--;
  192. }, 1000);
  193. //调用验证码接口
  194. verify({
  195. phone: obj.phone,
  196. type: 'register'
  197. })
  198. .then(({ data }) => {})
  199. .catch(err => {
  200. console.log(err);
  201. });
  202. }
  203. },
  204. login() {
  205. //返回登录
  206. uni.navigateTo({
  207. url: '/pages/public/login'
  208. });
  209. }
  210. }
  211. };
  212. </script>
  213. <style lang="scss">
  214. page {
  215. height: 100%;
  216. }
  217. .container {
  218. width: 100%;
  219. height: 100%;
  220. background-size: 100%;
  221. background-color: #fff;
  222. }
  223. .container_text {
  224. width: 100%;
  225. height: 500rpx;
  226. top: 0rpx;
  227. // background-color: #FF4343;
  228. .banner-img {
  229. width: 100%;
  230. height: 100%;
  231. }
  232. }
  233. .login_text {
  234. margin: auto 30rpx;
  235. position: relative;
  236. padding: 100rpx 102rpx;
  237. background-color: #ffffff;
  238. // margin-top: -180rpx;
  239. border-radius: 20rpx;
  240. .login_input {
  241. border-bottom: 1px solid #f0f0f0;
  242. margin-bottom: 65rpx;
  243. .login_img image {
  244. height: 35rpx;
  245. width: 29rpx;
  246. margin-right: 20rpx;
  247. }
  248. .uni-input {
  249. text-align: left;
  250. width: 470rpx;
  251. font-size: 28rpx !important;
  252. position: relative;
  253. image {
  254. width: 30rpx;
  255. height: 30rpx;
  256. position: absolute;
  257. right: 0;
  258. }
  259. }
  260. .login_name {
  261. color: #333333;
  262. }
  263. }
  264. .other {
  265. margin-top: 60rpx;
  266. .fenge {
  267. width: 30%;
  268. height: 2rpx;
  269. background-color: #eeeeee;
  270. }
  271. .qita {
  272. font-size: 28rpx;
  273. color: #999999;
  274. }
  275. }
  276. .weixin {
  277. width: 75rpx;
  278. height: 75rpx;
  279. margin: 25rpx auto;
  280. }
  281. .weixin image {
  282. width: 100%;
  283. height: 100%;
  284. }
  285. .weixin_text {
  286. text-align: center;
  287. font-size: 28rpx;
  288. color: #999999;
  289. }
  290. .forget {
  291. font-size: 28rpx;
  292. width: 100%;
  293. text-align: right;
  294. color: #999999;
  295. }
  296. .uni-button-green {
  297. color: #ffffff;
  298. background-color: $base-color;
  299. margin: 40rpx 10rpx;
  300. border-radius: 10rpx;
  301. }
  302. .uni-button-green-plain {
  303. border: 1px solid $base-color;
  304. margin: 40rpx 10rpx;
  305. border-radius: 50rpx;
  306. color: $base-color;
  307. background-color: #ffffff;
  308. }
  309. .uni-button {
  310. height: 85rpx;
  311. line-height: 85rpx;
  312. }
  313. }
  314. .loginTitle {
  315. position: absolute;
  316. top: 250rpx;
  317. width: 100%;
  318. text-align: center;
  319. color: white;
  320. font-size: 40rpx;
  321. }
  322. .forget {
  323. width: 100rpx;
  324. font-size: 24rpx;
  325. color: #ffffff;
  326. margin: 0px auto;
  327. border-bottom: 1px solid #ffffff;
  328. }
  329. .width {
  330. width: 325rpx !important;
  331. }
  332. .code {
  333. color: $base-color;
  334. font-size: 23rpx;
  335. border-left: 1px solid #eeeeee;
  336. width: 150rpx;
  337. flex-shrink: 0;
  338. text-align: center;
  339. }
  340. uni-button {
  341. height: 80rpx !important;
  342. line-height: 80rpx !important;
  343. }
  344. </style>