register.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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. }else if(obj.pay_type == '支付宝') {
  162. paytype = 'ali'
  163. }
  164. register({
  165. account: obj.phone, //账号
  166. captcha: obj.code, //验证码
  167. password: obj.password ,//密码
  168. parent: obj.invitation,//接点人uid
  169. parent_area: obj.parent_area,//区域
  170. pay_type: paytype,
  171. use_integral: obj.isSelsect ? '1':'0',
  172. from: 'APP'
  173. }).then(({da}) => {
  174. if (obj.pay_type == 'weixin' || obj.pay_type == 'routine') {
  175. // let da = data.result.jsConfig;
  176. console.log('--da--', da);
  177. let data = {
  178. appid:da.appid,
  179. noncestr: da.noncestr,
  180. package: da.package,
  181. partnerid:da.partnerid,
  182. prepayid:da.prepayid,
  183. timestamp: da.timestamp,
  184. sign:da.sign
  185. };
  186. console.log('--data--', data);
  187. uni.requestPayment({
  188. provider: 'wxpay',
  189. orderInfo: data,
  190. success(res) {
  191. console.log(res)
  192. }
  193. })
  194. }
  195. if (obj.pay_type == 'ali') {
  196. const url = data.result.jsConfig;
  197. console.log(url, 'url');
  198. uni.requestPayment({
  199. provider: 'alipay',
  200. orderInfo: url,
  201. success: res => {
  202. console.log(res);
  203. uni.showToast({
  204. title: '支付成功',
  205. duration: 2000
  206. });
  207. },
  208. fail: e => {
  209. console.log(e);
  210. },
  211. complete: () => {}
  212. });
  213. obj.payLoding = false;
  214. }
  215. if (obj.pay_type == 'yue' || obj.pay_type == 'brokerage'){
  216. uni.showToast({
  217. title:'注册成功',
  218. duration:2000,
  219. position:'top'
  220. });
  221. setTimeout(function () {
  222. uni.navigateTo({
  223. url: '/pages/user/jiedian'
  224. });
  225. },1000)
  226. }
  227. }).catch( err => {
  228. console.log(err)
  229. })
  230. },
  231. //发送验证码
  232. verification() {
  233. let obj = this;
  234. if (this.phone == '') {
  235. this.$api.msg('请输入电话号码');
  236. return;
  237. }
  238. if (this.phone.length < 11) {
  239. this.$api.msg('请输入正确的手机号');
  240. return;
  241. }
  242. // 判断是否在倒计时
  243. if (obj.countDown > 0) {
  244. return false;
  245. } else {
  246. obj.countDown = 60;
  247. obj.time = setInterval(() => {
  248. obj.countDown--;
  249. }, 1000);
  250. //调用验证码接口
  251. verify({
  252. phone: obj.phone,
  253. type: 'register'
  254. })
  255. .then(({ data }) => {})
  256. .catch(err => {
  257. console.log(err);
  258. });
  259. }
  260. },
  261. login() {
  262. //返回登录
  263. uni.navigateTo({
  264. url: '/pages/public/login'
  265. });
  266. }
  267. }
  268. };
  269. </script>
  270. <style lang="scss">
  271. page {
  272. height: 100%;
  273. }
  274. .container {
  275. width: 100%;
  276. height: 100%;
  277. background-size: 100%;
  278. background-color: #fff;
  279. }
  280. .container_text {
  281. width: 100%;
  282. height: 500rpx;
  283. top: 0rpx;
  284. // background-color: #FF4343;
  285. .banner-img {
  286. width: 100%;
  287. height: 100%;
  288. }
  289. }
  290. .login_text {
  291. margin: auto 30rpx;
  292. position: relative;
  293. padding: 100rpx 102rpx;
  294. background-color: #ffffff;
  295. // margin-top: -180rpx;
  296. border-radius: 20rpx;
  297. .login_input {
  298. border-bottom: 1px solid #f0f0f0;
  299. margin-bottom: 65rpx;
  300. .login_img image {
  301. height: 35rpx;
  302. width: 29rpx;
  303. margin-right: 20rpx;
  304. }
  305. .uni-input {
  306. text-align: left;
  307. width: 470rpx;
  308. font-size: 28rpx !important;
  309. position: relative;
  310. image {
  311. width: 30rpx;
  312. height: 30rpx;
  313. position: absolute;
  314. right: 0;
  315. }
  316. }
  317. .login_name {
  318. color: #333333;
  319. }
  320. }
  321. .other {
  322. margin-top: 60rpx;
  323. .fenge {
  324. width: 30%;
  325. height: 2rpx;
  326. background-color: #eeeeee;
  327. }
  328. .qita {
  329. font-size: 28rpx;
  330. color: #999999;
  331. }
  332. }
  333. .weixin {
  334. width: 75rpx;
  335. height: 75rpx;
  336. margin: 25rpx auto;
  337. }
  338. .weixin image {
  339. width: 100%;
  340. height: 100%;
  341. }
  342. .weixin_text {
  343. text-align: center;
  344. font-size: 28rpx;
  345. color: #999999;
  346. }
  347. .forget {
  348. font-size: 28rpx;
  349. width: 100%;
  350. text-align: right;
  351. color: #999999;
  352. }
  353. .uni-button-green {
  354. color: #ffffff;
  355. background-color: $base-color;
  356. margin: 40rpx 10rpx;
  357. border-radius: 10rpx;
  358. }
  359. .uni-button-green-plain {
  360. border: 1px solid $base-color;
  361. margin: 40rpx 10rpx;
  362. border-radius: 50rpx;
  363. color: $base-color;
  364. background-color: #ffffff;
  365. }
  366. .uni-button {
  367. height: 85rpx;
  368. line-height: 85rpx;
  369. }
  370. }
  371. .loginTitle {
  372. position: absolute;
  373. top: 250rpx;
  374. width: 100%;
  375. text-align: center;
  376. color: white;
  377. font-size: 40rpx;
  378. }
  379. .forget {
  380. width: 100rpx;
  381. font-size: 24rpx;
  382. color: #ffffff;
  383. margin: 0px auto;
  384. border-bottom: 1px solid #ffffff;
  385. }
  386. .width {
  387. width: 325rpx !important;
  388. }
  389. .code {
  390. color: $base-color;
  391. font-size: 23rpx;
  392. border-left: 1px solid #eeeeee;
  393. width: 150rpx;
  394. flex-shrink: 0;
  395. text-align: center;
  396. }
  397. uni-button {
  398. height: 80rpx !important;
  399. line-height: 80rpx !important;
  400. }
  401. </style>