register.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <template>
  2. <div class="page">
  3. <my-nav :title="'注册'" :hideIcon="true"></my-nav>
  4. <div class="main" v-if="step === 1">
  5. <!-- <div class="tit">注册</div> -->
  6. <div class="inp-box">
  7. <input
  8. type="number"
  9. name="mobile"
  10. v-model="form.mobile"
  11. placeholder="手机号码"
  12. />
  13. </div>
  14. <div class="inp-box code-box">
  15. <input
  16. type="number"
  17. name="smsCode"
  18. v-model="form.smsCode"
  19. placeholder="验证码"
  20. />
  21. <span
  22. class="code-btn"
  23. :class="{ dis: timeing }"
  24. @click="getCode()"
  25. >{{ codeStr }}</span
  26. >
  27. </div>
  28. <div class="inp-box">
  29. <input
  30. type="password"
  31. name="password"
  32. v-model="form.password"
  33. placeholder="请输入密码"
  34. />
  35. </div>
  36. <div class="inp-box">
  37. <input
  38. type="password"
  39. name="password2"
  40. v-model="form.password2"
  41. placeholder="确认密码"
  42. />
  43. </div>
  44. <button class="btn" @click="submit">注册</button>
  45. <p class="go-login">
  46. <a
  47. class="text"
  48. @click="
  49. jump({ path: '/pages/index/login', isTabBar: true })
  50. "
  51. >已有帐号,去登录</a
  52. >
  53. </p>
  54. </div>
  55. <div class="main" v-if="step === 2">
  56. <div class="tit">填写区区购团长号</div>
  57. <div class="inp-box">
  58. <input
  59. type="number"
  60. name="teamNum"
  61. v-model="form.teamNum"
  62. placeholder="团长号:9000xxxxxx"
  63. />
  64. </div>
  65. <button class="btn" @click="saveTeamNum">下一步</button>
  66. <div class="team-num-des">
  67. <h1 class="tit">在哪里看京东区区购团长号?</h1>
  68. <p class="text">
  69. 在京东区区购店长版后台,个人中心,点击头像进去就可以看到
  70. </p>
  71. <div class="video">
  72. <video
  73. src="https://oss.ixiaokejia.com/videos/get-pid.mp4"
  74. poster="https://oss.ixiaokejia.com/images/common/video_poster.png"
  75. ></video>
  76. </div>
  77. <p
  78. class="text"
  79. @click="copy('jingzhunwlyx', '复制客服微信成功')"
  80. >
  81. 如有问题,添加客服微信:<span class="wechat"
  82. >jingzhunwlyx</span
  83. >
  84. <span class="copy">点击复制</span
  85. >,或长按下方二维码添加客服咨询
  86. </p>
  87. <div class="img">
  88. <my-image
  89. mode="widthFix"
  90. @click="
  91. viewImg(
  92. 'https://oss.ixiaokejia.com/images/common/kefu_qrcode.jpg'
  93. )
  94. "
  95. src="https://oss.ixiaokejia.com/images/common/kefu_qrcode.jpg"
  96. ></my-image>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="main" v-if="step === 3">
  101. <div class="return-page" @click="step=2">
  102. <my-image
  103. class="arrow"
  104. src="/static/common/arrows_left.png"
  105. ></my-image
  106. >返回填写团长号
  107. </div>
  108. <div class="tit">添加助理微信</div>
  109. <ul class="add-assistant">
  110. <li @click="copy(kefu._id, '复制群助理微信成功')">
  111. <div class="step">第一步:</div>
  112. <div class="con">
  113. <div>
  114. 助理微信:<span class="wechat">{{ kefu._id }}</span>
  115. <span class="copy">点击复制</span>
  116. </div>
  117. <my-image
  118. class="wechat-img"
  119. mode="widthFix"
  120. @click="viewImg(kefu.qrCode)"
  121. :src="kefu.qrCode"
  122. ></my-image>
  123. </div>
  124. </li>
  125. <li>
  126. <div class="step">第二步:</div>
  127. <div class="con">
  128. <div class="font-blod">将助理拉入群</div>
  129. </div>
  130. </li>
  131. <li>
  132. <div class="step">第三步:</div>
  133. <div class="con">
  134. <div>在群里@群助理</div>
  135. </div>
  136. </li>
  137. <li
  138. @click="
  139. copy(
  140. pidCode,
  141. '已复制群验证码,请粘贴发送到要开通助理的群内'
  142. )
  143. "
  144. >
  145. <div class="step">第四步:</div>
  146. <div class="con">
  147. <div>
  148. 发送
  149. <span class="wechat red">{{ pidCode }}</span> 到群内
  150. <span class="copy">点击复制</span>
  151. </div>
  152. </div>
  153. </li>
  154. </ul>
  155. <button class="btn" @click="saveOk">已完成</button>
  156. </div>
  157. </div>
  158. </template>
  159. <script>
  160. import MyImage from "../../components/image/index";
  161. import MyNav from "../../components/layout/nav";
  162. export default {
  163. name: "",
  164. components: { MyImage, MyNav },
  165. // 数据
  166. data() {
  167. return {
  168. step: 1,
  169. form: {
  170. mobile: "",
  171. smsCode: "",
  172. password: "",
  173. password2: "",
  174. teamNum: "",
  175. fromPlatform: 1,
  176. },
  177. timeing: false,
  178. codeStr: "发送验证码",
  179. pidCode: "",
  180. kefu: {},
  181. share: {
  182. title: "开通群助理",
  183. path: "/pages/index/register",
  184. imageUrl:
  185. "https://oss.ixiaokejia.com/images/common/share_register.jpg",
  186. },
  187. };
  188. },
  189. onLoad(opts) {
  190. if (opts.step) {
  191. this.step = Number(opts.step);
  192. if (this.step !== 1) {
  193. this.getAvailableWechat();
  194. }
  195. }
  196. if (opts.pidCode) {
  197. this.pidCode = opts.pidCode;
  198. }
  199. if (opts.fromPlatform) {
  200. this.form.fromPlatform = Number(opts.fromPlatform);
  201. }
  202. uni.hideLoading();
  203. },
  204. onShow() {},
  205. // 函数
  206. methods: {
  207. getAvailableWechat() {
  208. this.api
  209. .get("/Group/GetAvailableWechat", {}, { pass: true })
  210. .then((res) => {
  211. if (res.data.length === 0) {
  212. this.fn.showModal({
  213. title: "提示",
  214. content:
  215. "暂时所有群助理都已经排满,请您联系客服或稍后再试。客服微信:jingzhunwlyx",
  216. showCancel: false,
  217. });
  218. } else {
  219. this.kefu = res.data[0] ? res.data[0] : {};
  220. console.log(this.kefu);
  221. }
  222. });
  223. },
  224. getCode() {
  225. if (this.timeing) {
  226. return;
  227. }
  228. let phoneReg = /^[1][1-9][0-9]{9}$/;
  229. if (!this.form.mobile) {
  230. return this.fn.showToast("请输入手机号");
  231. }
  232. if (!phoneReg.test(this.form.mobile)) {
  233. return this.fn.showToast("手机号格式不正确");
  234. }
  235. this.sendCode();
  236. this.downTime();
  237. },
  238. sendCode() {
  239. this.api
  240. .get("/Login/SendSms", { mobile: this.form.mobile })
  241. .then((res) => {});
  242. },
  243. downTime() {
  244. this.timeing = true;
  245. let t = 60;
  246. this.codeStr = t + "s重新获取";
  247. let timer = setInterval(() => {
  248. t--;
  249. if (t === 0) {
  250. clearInterval(timer);
  251. this.codeStr = "发送验证码";
  252. this.timeing = false;
  253. } else {
  254. this.codeStr = t + "s重新获取";
  255. }
  256. }, 1000);
  257. },
  258. submit() {
  259. if (!this.form.mobile) {
  260. this.fn.showToast(`请输入手机号码`);
  261. return;
  262. }
  263. if (!this.form.smsCode) {
  264. this.fn.showToast(`请输入验证码`);
  265. return;
  266. }
  267. if (!this.form.password) {
  268. this.fn.showToast(`请输入密码`);
  269. return;
  270. }
  271. if (this.form.password.length < 6) {
  272. this.fn.showToast(`密码最少6位`);
  273. return;
  274. }
  275. if (!this.form.password2) {
  276. this.fn.showToast(`请输入确认密码`);
  277. return;
  278. }
  279. if (this.form.password2 !== this.form.password) {
  280. this.fn.showToast(`两次密码不一致`);
  281. return;
  282. }
  283. uni.showLoading({
  284. title: "提交中",
  285. });
  286. // this.step = 2;
  287. let sendData = {
  288. code: "",
  289. mobile: this.form.mobile,
  290. smsCode: this.form.smsCode,
  291. password: this.form.password,
  292. fromPlatform: this.form.fromPlatform,
  293. };
  294. uni.login({
  295. provider: "weixin",
  296. success: (result) => {
  297. sendData.code = result.code;
  298. this.api.post("/Login/Register", sendData).then((res) => {
  299. uni.hideLoading();
  300. if (res.success) {
  301. res.data.companyId = res.data.companyId || null;
  302. this.fn.showToast(`注册成功`);
  303. // 正常用户
  304. this.$store.commit("user/login", res.data);
  305. this.$store.commit("common/update", {
  306. curShop: {},
  307. });
  308. this.step = 2;
  309. this.getAvailableWechat();
  310. } else {
  311. this.fn.showModal({
  312. title: "注册失败",
  313. content: res.message,
  314. showCancel: false,
  315. });
  316. }
  317. });
  318. },
  319. });
  320. },
  321. saveTeamNum() {
  322. if (!this.form.teamNum) {
  323. return this.fn.showToast(`请输入团长号`);
  324. }
  325. let reg = /^9\d{9}$/;
  326. if (!reg.test(this.form.teamNum)) {
  327. return this.fn.showToast("团长号为9开头的10位数字");
  328. }
  329. uni.showLoading({
  330. title: "提交中",
  331. });
  332. // this.step = 2;
  333. this.form.fromPlatform = 1;
  334. let sendData = {
  335. pid: this.form.teamNum,
  336. platform: this.form.fromPlatform,
  337. };
  338. this.api
  339. .post("/Group/CommitPid", sendData, { pass: true })
  340. .then((res) => {
  341. uni.hideLoading();
  342. if (res.success) {
  343. this.fn.showToast(`团长号提交成功`);
  344. this.pidCode = res.data;
  345. this.step = 3;
  346. } else {
  347. this.fn.showModal({
  348. title: "团长号提交失败",
  349. content: res.message,
  350. showCancel: false,
  351. });
  352. }
  353. });
  354. },
  355. viewImg(url) {
  356. uni.previewImage({
  357. urls: [url],
  358. });
  359. },
  360. copy(val, str) {
  361. const self = this;
  362. uni.setClipboardData({
  363. data: val,
  364. success: () => {
  365. self.fn.showToast(str || "复制成功");
  366. },
  367. });
  368. },
  369. saveOk() {
  370. // this.router.push("/pages/index/register?step=2");
  371. // return;
  372. // self.fn.showToast("注册成功");
  373. this.api
  374. .get("/Group/CheckCode", {
  375. platform: this.form.fromPlatform,
  376. })
  377. .then((res) => {
  378. if (res.success) {
  379. if (res.data.verified) {
  380. this.router.push({
  381. path: "/pages/assistant/index",
  382. isTabBar: true,
  383. });
  384. } else {
  385. this.fn.showModal({
  386. title: "失败",
  387. content:
  388. "助理没有收到您发送在群里的团长号,请确认1、2、3步全部完成后再试",
  389. showCancel: false,
  390. });
  391. }
  392. } else {
  393. this.fn
  394. .showModal({
  395. title: "未填写团长号",
  396. content: "确认返回团长号填写",
  397. showCancel: false,
  398. })
  399. .then((res) => {
  400. if (res.confirm) {
  401. this.step = 2;
  402. }
  403. });
  404. // this.router.push("/index/register?step=2");
  405. }
  406. });
  407. },
  408. },
  409. // 数据计算
  410. computed: {},
  411. // 数据监听
  412. watch: {},
  413. };
  414. </script>
  415. <style lang="scss" scoped>
  416. .page {
  417. height: 100vh;
  418. background-color: #fff;
  419. }
  420. .main {
  421. padding-top: px(120);
  422. padding-left: px(40);
  423. padding-right: px(40);
  424. }
  425. .tit {
  426. font-size: px(50);
  427. padding-bottom: px(100);
  428. text-align: center;
  429. padding-bottom: px(100);
  430. }
  431. .inp-box {
  432. display: flex;
  433. justify-content: space-between;
  434. align-items: center;
  435. border-bottom: 1px solid #c3c1c2;
  436. padding: px(30) 0;
  437. margin-bottom: px(30);
  438. }
  439. .inp-box span {
  440. font-size: px(32);
  441. color: rgb(0, 188, 38);
  442. border-radius: px(15);
  443. border: 1px solid rgb(0, 188, 38);
  444. width: px(230);
  445. height: px(80);
  446. text-align: center;
  447. line-height: px(80);
  448. flex-shrink: 0;
  449. margin-left: px(30);
  450. }
  451. .inp-box input {
  452. width: 100%;
  453. }
  454. .inp-box .dis {
  455. color: #999;
  456. border-color: #999;
  457. pointer-events: none;
  458. }
  459. .btn {
  460. margin-top: px(120);
  461. color: #fff;
  462. background-color: rgb(0, 188, 38);
  463. font-size: px(44);
  464. }
  465. .code-box {
  466. display: flex;
  467. justify-content: space-between;
  468. align-items: center;
  469. .code-btn {
  470. width: px(250);
  471. flex-shrink: 0;
  472. font-size: px(40);
  473. padding: 0 px(10);
  474. border: none;
  475. &.dis {
  476. border-color: #f1f1f1;
  477. color: #999;
  478. }
  479. }
  480. }
  481. .team-num-des {
  482. padding: px(80) px(30);
  483. text-align: center;
  484. line-height: 1.5;
  485. .tit {
  486. font-size: px(48);
  487. padding: px(10) 0;
  488. }
  489. .text {
  490. font-size: px(44);
  491. padding: px(15) 0;
  492. }
  493. video {
  494. width: 80vw;
  495. height: calc(80vw / 0.466666);
  496. display: block;
  497. margin: 0 auto;
  498. }
  499. .img,
  500. .video {
  501. padding: px(20) 0;
  502. }
  503. /deep/ img {
  504. width: 80%;
  505. display: block;
  506. margin: 0 auto;
  507. }
  508. }
  509. .add-assistant {
  510. border-top: 1px solid #f1f1f1;
  511. li {
  512. display: flex;
  513. justify-content: space-between;
  514. font-size: px(44);
  515. padding: px(30);
  516. border-bottom: 1px solid #f1f1f1;
  517. .step {
  518. width: px(200);
  519. flex-shrink: 0;
  520. font-weight: bold;
  521. }
  522. .con {
  523. width: 100%;
  524. }
  525. .wechat-img {
  526. padding: px(10);
  527. /deep/ img {
  528. width: px(600);
  529. }
  530. }
  531. }
  532. }
  533. .copy {
  534. display: inline-block;
  535. font-size: px(32);
  536. line-height: px(44);
  537. padding: 0 px(10);
  538. border: 1px solid #4395ff;
  539. color: #4395ff;
  540. background-color: #fff;
  541. margin-left: px(20);
  542. border-radius: px(5);
  543. transform: translate(0, -1px);
  544. }
  545. .wechat {
  546. color: #4395ff;
  547. &.red {
  548. color: red;
  549. font-weight: bold;
  550. }
  551. }
  552. .go-login {
  553. text-align: center;
  554. padding-top: px(60);
  555. .text {
  556. display: inline-block;
  557. color: #4395ff;
  558. }
  559. }
  560. .font-blod {
  561. font-weight: bold;
  562. }
  563. .return-page {
  564. font-size: px(40);
  565. color: #333;
  566. display: flex;
  567. justify-content: flex-start;
  568. align-items: center;
  569. transform: translate(0,px(-80));
  570. color: #666;
  571. .arrow {
  572. width: px(40);
  573. height: px(40);
  574. flex-shrink: 0;
  575. margin-right: px(20);
  576. /deep/ img {
  577. width: px(40);
  578. height: px(40);
  579. }
  580. }
  581. }
  582. </style>