orderissuer.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class="page">
  3. <!-- 公共组件-每个页面必须引入 -->
  4. <public-module></public-module>
  5. <view class="mx-3 mt-3">
  6. <!-- 账号密码登录 false代表账号密码登录 -->
  7. <view class="phone d-flex">
  8. <view class="title">电话号码</view>
  9. <input placeholder="请输入手机号" v-model="phone" maxlength="11" />
  10. </view>
  11. <view class="phone d-flex">
  12. <view class="title">真实姓名</view>
  13. <input placeholder="请输入姓名" v-model="name" />
  14. </view>
  15. <view class="password d-flex">
  16. <view class="title">密码</view>
  17. <input placeholder="请输入密码" v-model="password" :password='isHidePassword' maxlength="15"
  18. style="padding-right: 200rpx;" />
  19. <view class="d-flex a-center j-center yanzhengma">
  20. <view style="font-size: 40rpx;" class="icon iconfont"
  21. :class="isHidePassword?'icon-buxianshimima':'icon-xianshimima'"
  22. @tap="isHidePassword = !isHidePassword"></view>
  23. </view>
  24. </view>
  25. <view class="code d-flex">
  26. <view class="title">验证码</view>
  27. <input placeholder="请输入验证码" v-model="code" maxlength="5" style="padding-right: 200rpx;" />
  28. <view class="d-flex a-center j-center login-font-color yanzhengma" @tap="getCheckNum">
  29. <view class="d-flex a-center j-center"
  30. :class="!codetime?'yanzhengma1 main-text-color':'yanzhengma2'">
  31. {{!codetime?'获取验证码':codetime+' s'}}
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 推荐信息 -->
  36. <template v-if="showRecommend">
  37. <view class="recommendInfo">
  38. <view class="d-flex">
  39. <view>
  40. <image src="/static/bigLogo.png"></image>
  41. </view>
  42. <view>
  43. <view><span class="text-muted mr-2">推荐人姓名</span> {{recommendername}}</view>
  44. <view><span class="text-muted mr-2">推荐人会员号</span> {{recommenderid}}</view>
  45. </view>
  46. </view>
  47. <view class="px-3 py-1 d-flex a-center j-center">请确认推荐人信息,注册后,推荐人将不可修改</view>
  48. </view>
  49. </template>
  50. <button class="my-3 mt-4 d-flex a-center j-center font-weight main-bg-color" :loading="loading"
  51. :class="{'main-bf-hover-color':disabled}" type="primary" @tap="submit" :disabled="disabled"
  52. style="letter-spacing: 20rpx;">注册</button>
  53. <!-- <view class="d-flex a-center j-center my-3">
  54. 已有帐号?<view class="main-text-color" @tap="navigate({url:'/pages/login/login'},'reLaunch')">去登录</view>
  55. </view> -->
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. pathToBase64,
  62. base64ToPath
  63. } from '@/common/image-tools-base64.js';
  64. import {
  65. mapMutations
  66. } from "vuex"
  67. export default {
  68. data() {
  69. return {
  70. name: "",
  71. phone: "",
  72. password: "",
  73. code: "",
  74. isHidePassword: true,
  75. disabled: true,
  76. loading: false,
  77. codetime: 0,
  78. showRecommend: false,
  79. recommendername: "",
  80. recommenderid: ""
  81. }
  82. },
  83. async onLoad(params) {
  84. // // #ifdef H5
  85. // document.getElementsByTagName('uni-page-head')[0].style.display = 'none'
  86. // // #endif
  87. if (params.id) {
  88. this.recommenderid = params.id;
  89. // 查询推荐人信息
  90. let res = await this.$http.get('/user/findById?id=' + params.id);
  91. if ((res.code == '200') && (res.data != null)) {
  92. this.recommendername = res.data.name;
  93. this.showRecommend = true;
  94. } else {
  95. uni.showToast({
  96. title: res.msg,
  97. icon: "success",
  98. duration: 2000
  99. });
  100. this.showRecommend = false;
  101. // if(this.$base.baseUrl.indexOf("test")>-1){
  102. // this.recommenderid="99140109M01D01001";
  103. // this.recommendername = "耿陈杰";
  104. // this.showRecommend = false;
  105. // }else{
  106. // this.recommenderid="99140109M03D01001";
  107. // this.recommendername = "掌柜老王";
  108. // this.showRecommend = false;
  109. // }
  110. }
  111. }
  112. // else{
  113. // if(this.$base.baseUrl.indexOf("test")>-1){
  114. // this.recommenderid="99140109M01D01001";
  115. // this.recommendername = "耿陈杰";
  116. // this.showRecommend = false;
  117. // }else{
  118. // this.recommenderid="99140109M03D01001";
  119. // this.recommendername = "掌柜老王";
  120. // this.showRecommend = false;
  121. // }
  122. // }
  123. },
  124. watch: {
  125. name() {
  126. this.OnBtnChange();
  127. },
  128. phone(val) {
  129. this.OnBtnChange();
  130. },
  131. password(val) {
  132. this.OnBtnChange();
  133. },
  134. code(val) {
  135. this.OnBtnChange();
  136. }
  137. },
  138. methods: {
  139. ...mapMutations(['setUserModules']),
  140. // 改变按钮状态
  141. OnBtnChange() {
  142. if (this.phone && this.password && this.code && this.name) {
  143. this.disabled = false;
  144. return;
  145. }
  146. this.disabled = true;
  147. },
  148. isPwdRules() {
  149. let mPattern = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;
  150. return mPattern.test(this.password);
  151. },
  152. // 获取验证码
  153. async getCheckNum() {
  154. uni.hideKeyboard();
  155. if (this.codetime > 0) return;
  156. // 验证手机号合法性
  157. if (!this.phone) {
  158. return uni.showToast({
  159. title: '请输入手机号',
  160. icon: 'none'
  161. });
  162. }
  163. if (!this.$base.phoneRegular.test(this.phone)) {
  164. return uni.showToast({
  165. title: '请输入正确的手机号码',
  166. icon: 'none'
  167. });
  168. }
  169. // 请求服务器,发送验证码
  170. let res = await this.$http.get('/sendMsg', {
  171. phone: this.phone,
  172. type: "1"
  173. });
  174. // 请求失败处理
  175. if (res.code != 200) {
  176. return uni.showToast({
  177. title: res.data.msg,
  178. icon: "none"
  179. });
  180. } else {
  181. uni.showToast({
  182. title: "发送成功",
  183. icon: "none"
  184. });
  185. }
  186. // 发送成功,开启倒计时
  187. this.codetime = 60;
  188. let timer = setInterval(() => {
  189. this.codetime--;
  190. if (this.codetime < 1) {
  191. clearInterval(timer);
  192. this.codetime = 0;
  193. }
  194. }, 1000);
  195. },
  196. // 提交注册
  197. async submit() {
  198. if (!this.name) {
  199. return uni.showToast({
  200. title: '请输入姓名',
  201. icon: 'none'
  202. });
  203. }
  204. // 验证手机号合法性
  205. if (!this.$base.phoneRegular.test(this.phone)) {
  206. return uni.showToast({
  207. title: '请输入正确的手机号码',
  208. icon: 'none'
  209. });
  210. }
  211. // 验证密码合法性
  212. if (!this.$base.passwordRegular.test(this.password)) {
  213. return uni.showToast({
  214. title: '密码须6-15位数字与字母组合',
  215. icon: 'none'
  216. });
  217. }
  218. // 请求服务器,发送验证码
  219. let res = await this.$http.post('/user/agentRegist', {
  220. "name": this.name,
  221. "password": this.password,
  222. "mobile": this.phone,
  223. "mobileMsg": this.code,
  224. "referrerId": this.recommenderid,
  225. "referrerName": this.recommendername,
  226. "flag": 2,
  227. });
  228. // 请求失败处理
  229. // var newPhone= "";
  230. // newPhone = this.phone;
  231. // this.password="";
  232. // this.phone="";
  233. // this.code="";
  234. // this.name="";
  235. if ((res.code == 200) && (!!res.data)) {
  236. // #ifndef H5
  237. this.setUserModules({
  238. title: "userLoginId",
  239. data: res.data
  240. })
  241. uni.showToast({
  242. title: '注册成功',
  243. icon: "success",
  244. duration: 2000
  245. });
  246. setTimeout(() => {
  247. return uni.reLaunch({
  248. url: "/pages/login/login"
  249. })
  250. }, 2000);
  251. // #endif
  252. // #ifdef H5
  253. setTimeout(() => {
  254. return uni.reLaunch({
  255. url: "/pages/register/registerSuccess?id=" + res.data + '&phone=' + this
  256. .phone
  257. })
  258. }, 2000);
  259. // #endif
  260. } else {
  261. uni.showToast({
  262. title: res.msg,
  263. icon: "none",
  264. duration: 2000
  265. });
  266. }
  267. // else{
  268. // uni.showToast({ title: '已注册,重复注册', icon:"success",duration:2000 });
  269. // }
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. @import '@/style/mixin.scss';
  276. .idCardBefore {
  277. background: rgba($themeColor, 0.1) url('/static/image/user/identy2.png') center center no-repeat;
  278. background-size: auto 70%;
  279. padding: 10upx;
  280. }
  281. .page {
  282. background: #F5F5F5;
  283. height: 100vh;
  284. width: 100%;
  285. position: absolute;
  286. }
  287. .phone,
  288. .password,
  289. .code {
  290. position: relative;
  291. height: 90upx;
  292. display: flex;
  293. align-items: center;
  294. background-color: #FFFFFF;
  295. padding: 0 30upx;
  296. margin-bottom: 26upx;
  297. }
  298. .phone .title,
  299. .password .title,
  300. .code .title {
  301. width: 160upx;
  302. flex-shrink: 0;
  303. color: #666;
  304. }
  305. .phone input,
  306. .password input,
  307. .code input {
  308. width: 350upx;
  309. font-size: 28upx;
  310. }
  311. .yanzhengma {
  312. width: 150upx;
  313. position: absolute;
  314. right: 30upx;
  315. }
  316. .yanzhengma1 {
  317. font-size: 26upx;
  318. background: #FFFFFF;
  319. border-radius: 10rpx;
  320. width: 150rpx;
  321. padding: 5rpx 0;
  322. }
  323. .yanzhengma2 {
  324. background: #FFFFFF;
  325. font-size: 26upx;
  326. color: #B2B2B2;
  327. border-radius: 10rpx;
  328. width: 150rpx;
  329. padding: 5rpx 0;
  330. }
  331. .recommendInfo {
  332. background: #FFFFFF;
  333. }
  334. .recommendInfo>view:nth-of-type(1) {
  335. border-bottom: 1px solid #ddd;
  336. }
  337. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(1) {
  338. width: 150upx;
  339. height: 150upx;
  340. border-radius: 50%;
  341. }
  342. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(1)>image {
  343. width: 100%;
  344. height: 100%;
  345. }
  346. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(2) {
  347. padding: 20upx;
  348. }
  349. .recommendInfo>view:nth-of-type(1)>view:nth-of-type(2)>view {
  350. height: 55upx;
  351. }
  352. .recommendInfo>view:nth-of-type(2) {
  353. line-height: 50upx;
  354. }
  355. </style>