register.vue 8.7 KB

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