register.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <s-layout title="新用户注册" :bgStyle="{ color: '#fff' }">
  3. <view class="content-block">
  4. <uni-forms
  5. ref="registerRef"
  6. v-model="state.model"
  7. :rules="state.rules"
  8. validateTrigger="bind"
  9. labelWidth="140"
  10. labelAlign="left"
  11. labelPosition="top"
  12. >
  13. <uni-forms-item name="shopName" label="店铺名" required>
  14. <uni-easyinput
  15. placeholder="请输入店铺名"
  16. v-model="state.model.shopName"
  17. paddingLeft="15"
  18. >
  19. </uni-easyinput>
  20. </uni-forms-item>
  21. <uni-forms-item name="shopkeeperName" label="店主姓名" required>
  22. <uni-easyinput
  23. placeholder="请输入店主姓名"
  24. v-model="state.model.shopkeeperName"
  25. paddingLeft="15"
  26. >
  27. </uni-easyinput>
  28. </uni-forms-item>
  29. <uni-forms-item
  30. name="fullArea"
  31. label="省市区"
  32. required
  33. @tap="state.showRegion = true"
  34. >
  35. <uni-easyinput
  36. placeholder="点击选择"
  37. v-model="state.fullArea"
  38. type="number"
  39. paddingLeft="15"
  40. :styles="{ disableColor: 'transparent', borderColor: '#e5e5e5' }"
  41. disabled
  42. >
  43. <template #right>
  44. <image
  45. style="width: 24rpx; height: 15rpx; margin-right: 30rpx"
  46. :src="sheep.$url.static('/static/icons/arrow-down-icon.png')"
  47. mode=""
  48. ></image>
  49. </template>
  50. </uni-easyinput>
  51. </uni-forms-item>
  52. <uni-forms-item name="address" label="详细地址" required @tap="chooseAddress">
  53. <uni-easyinput
  54. placeholder="请输入详细地址"
  55. v-model="state.model.address"
  56. paddingLeft="15"
  57. disabled
  58. >
  59. <template #right>
  60. <view class="right-box" >
  61. <image
  62. style="width: 32rpx; height: 30rpx; margin-right: 30rpx"
  63. :src="sheep.$url.static('/static/icons/address-icon.png')"
  64. mode=""
  65. ></image>
  66. </view>
  67. </template>
  68. </uni-easyinput>
  69. </uni-forms-item>
  70. <uni-forms-item name="images" label="门头照片" required>
  71. <s-uploader
  72. v-model:url="state.images"
  73. fileMediatype="image"
  74. limit="5"
  75. mode="grid"
  76. :imageStyles="{ width: '200rpx', height: '200rpx' }"
  77. />
  78. </uni-forms-item>
  79. <uni-forms-item
  80. name="businessTime"
  81. label="营业时间"
  82. required
  83. @tap="showTime('businessTime')"
  84. >
  85. <uni-easyinput
  86. placeholder="请选择营业时间"
  87. v-model="state.model.businessTime"
  88. paddingLeft="15"
  89. :styles="{ disableColor: 'transparent', borderColor: '#e5e5e5' }"
  90. disabled
  91. >
  92. <template #right>
  93. <image
  94. style="width: 32rpx; height: 32rpx; margin-right: 30rpx"
  95. :src="sheep.$url.static('/static/icons/calendar-icon.png')"
  96. mode=""
  97. ></image>
  98. </template>
  99. </uni-easyinput>
  100. </uni-forms-item>
  101. <uni-forms-item
  102. name="deliveryTime"
  103. label="送货时间"
  104. required
  105. @tap="showTime('deliveryTime')"
  106. >
  107. <!-- 时间弹窗 -->
  108. <uni-easyinput
  109. placeholder="请选择送货时间"
  110. v-model="state.model.deliveryTime"
  111. paddingLeft="15"
  112. :styles="{ disableColor: 'transparent', borderColor: '#e5e5e5' }"
  113. disabled
  114. >
  115. <template #right>
  116. <image
  117. style="width: 32rpx; height: 32rpx; margin-right: 30rpx"
  118. :src="sheep.$url.static('/static/icons/calendar-icon.png')"
  119. mode=""
  120. ></image>
  121. </template>
  122. </uni-easyinput>
  123. </uni-forms-item>
  124. <uni-forms-item label="邀请码">
  125. <uni-easyinput
  126. placeholder="请输入邀请码"
  127. v-model="state.model.inviteCode"
  128. paddingLeft="15"
  129. type="number"
  130. >
  131. </uni-easyinput>
  132. </uni-forms-item>
  133. </uni-forms>
  134. <button class="toLoginBtn ss-reset-button" @tap="toRegister">注册</button>
  135. <view class="agreement-box ss-flex">
  136. <!-- <radio-group @change="onChange" class="ss-flex ss-col-center">
  137. <label class="radio ss-flex"> -->
  138. <radio
  139. :checked="protocol"
  140. color="var(&#45;&#45;ui-BG-Main)"
  141. style="transform: scale(0.8)"
  142. @tap.top="onChange"
  143. />
  144. <view class="agreement-text ss-flex ss-col-center ss-m-l-8" :class="{'isAgreement': protocol}">
  145. 我已阅读并同意
  146. <view
  147. class="tcp-text"
  148. @tap.stop="
  149. onProtocol(1, '用户协议', 'small:program:user:agreement')
  150. "
  151. >
  152. 《用户协议》
  153. </view>
  154. </view>
  155. <!-- </label>
  156. </radio-group> -->
  157. </view>
  158. </view>
  159. <view class="safe-box"></view>
  160. <uni-popup
  161. ref="timePopupRef"
  162. background-color="#fff"
  163. :mask-click="false"
  164. borderRadius="24rpx"
  165. >
  166. <su-toolbar
  167. cancelColor="#6666"
  168. confirmColor="var(--ui-BG-Main)"
  169. cancelText="取消"
  170. confirmText="确定"
  171. @cancel="timePopupRef.close()"
  172. @confirm="confirm"
  173. ></su-toolbar>
  174. <picker-view
  175. @change="bindChange"
  176. class="picker-view"
  177. :value="defaultIndex"
  178. >
  179. <picker-view-column>
  180. <view class="item" v-for="(item, index) in columns[0]" :key="index">{{
  181. item
  182. }}</view>
  183. </picker-view-column>
  184. <picker-view-column>
  185. <view class="item" v-for="(item, index) in columns[1]" :key="index">{{
  186. item
  187. }}</view>
  188. </picker-view-column>
  189. </picker-view>
  190. </uni-popup>
  191. <!-- 省市区弹窗 -->
  192. <su-region-picker
  193. v-if="state.showRegion"
  194. :show="state.showRegion"
  195. @cancel="state.showRegion = false"
  196. @confirm="onRegionConfirm"
  197. >
  198. </su-region-picker>
  199. <!-- 注册成功提示 -->
  200. <uni-popup
  201. ref="popupRef"
  202. background-color="#fff"
  203. :mask-click="false"
  204. borderRadius="24rpx"
  205. >
  206. <view class="popup-box">
  207. <view class="ss-flex ss-row-center">
  208. <image
  209. class="scuss-img"
  210. :src="sheep.$url.static('/static/registerScu-img.png')"
  211. mode=""
  212. ></image>
  213. </view>
  214. <view class="scuss-text"
  215. >您的注册申请已经提交,审核通过之后我们将会短信通知您</view
  216. >
  217. <button class="toHomeBtn ss-reset-button" @tap="toHome">
  218. 返回主页
  219. </button>
  220. </view>
  221. </uni-popup>
  222. <!-- <up-popup :show="registerScuShow" mode="center" :round="12" :closeOnClickOverlay="false" :safeAreaInsetBottom="false">
  223. </up-popup> -->
  224. </s-layout>
  225. </template>
  226. <script setup>
  227. import { onLoad } from "@dcloudio/uni-app";
  228. import sheep from "@/sheep";
  229. import _ from "lodash";
  230. import {
  231. shopName,
  232. shopkeeperName,
  233. fullArea,
  234. businessTime,
  235. deliveryTime,
  236. address,
  237. images,
  238. } from "@/sheep/validate/form";
  239. import { reactive, ref, unref } from "vue";
  240. const state = reactive({
  241. showRegion: false,
  242. codeText: "获取验证码",
  243. model: {
  244. phone: "",
  245. shopName: "",
  246. shopkeeperName: "",
  247. province: "",
  248. city: "",
  249. area: "",
  250. address: "",
  251. businessTime: "",
  252. deliveryTime: "",
  253. inviteCode:"",
  254. latitude:"",//纬度
  255. longitude:"",//经度
  256. },
  257. fullArea: "",
  258. images: [],
  259. rules: {
  260. shopName,
  261. shopkeeperName,
  262. fullArea,
  263. businessTime,
  264. deliveryTime,
  265. address,
  266. images,
  267. },
  268. });
  269. const protocol = ref(false);
  270. const popupRef = ref(null);
  271. const timePopupRef = ref(null);
  272. const registerScuShow = ref(false);
  273. const defaultIndex = ref([0, 0]);
  274. const timeType = ref();
  275. const timeShow = ref(true);
  276. const timeValue = ref([0, 0]);
  277. const columns = reactive([
  278. [
  279. "00:00",
  280. "01:00",
  281. "02:00",
  282. "03:00",
  283. "04:00",
  284. "05:00",
  285. "06:00",
  286. "07:00",
  287. "08:00",
  288. "09:00",
  289. "10:00",
  290. "11:00",
  291. "12:00",
  292. "13:00",
  293. "14:00",
  294. "15:00",
  295. "16:00",
  296. "17:00",
  297. "18:00",
  298. "19:00",
  299. "20:00",
  300. "21:00",
  301. "22:00",
  302. "23:00",
  303. ],
  304. [
  305. "00:00",
  306. "01:00",
  307. "02:00",
  308. "03:00",
  309. "04:00",
  310. "05:00",
  311. "06:00",
  312. "07:00",
  313. "08:00",
  314. "09:00",
  315. "10:00",
  316. "11:00",
  317. "12:00",
  318. "13:00",
  319. "14:00",
  320. "15:00",
  321. "16:00",
  322. "17:00",
  323. "18:00",
  324. "19:00",
  325. "20:00",
  326. "21:00",
  327. "22:00",
  328. "23:00",
  329. ],
  330. ]);
  331. onLoad((e) => {
  332. state.model.phone = e.mobile;
  333. getAreaData();
  334. });
  335. // 获取省市区
  336. const getAreaData = () => {
  337. if (_.isEmpty(uni.getStorageSync("areaData"))) {
  338. sheep.$api.data.area().then((res) => {
  339. if (res.code === 200) {
  340. uni.setStorageSync("areaData", res.data);
  341. }
  342. });
  343. }
  344. };
  345. const chooseAddress = ()=>{
  346. uni.chooseLocation({
  347. success:(res)=> {
  348. state.model.address = res.name
  349. state.model.latitude = res.latitude
  350. state.model.longitude = res.longitude
  351. // console.log('位置名称:' + res.name);
  352. // console.log('详细地址:' + res.address);
  353. // console.log('纬度:' + res.latitude);
  354. // console.log('经度:' + res.longitude);
  355. },
  356. fail:(err)=>{
  357. console.log(err,'err')
  358. }
  359. });
  360. }
  361. // 时间选择
  362. const showTime = (type) => {
  363. timeType.value = type;
  364. defaultIndex.value = [0, 0];
  365. timePopupRef.value.open("bottom");
  366. };
  367. const confirm = () => {
  368. state.model[timeType.value] =
  369. columns[0][timeValue.value[0]] + "-" + columns[1][timeValue.value[1]];
  370. timePopupRef.value.close();
  371. };
  372. const bindChange = (e) => {
  373. timeValue.value = e.detail.value;
  374. };
  375. //勾选协议
  376. function onChange() {
  377. protocol.value = !protocol.value;
  378. }
  379. const onRegionConfirm = (e) => {
  380. const { city_name, district_name, province_name } = e;
  381. state.fullArea = `${province_name}-${city_name}-${district_name}`;
  382. state.model = {
  383. ...state.model,
  384. province: province_name,
  385. city: city_name,
  386. area: district_name,
  387. };
  388. state.showRegion = false;
  389. };
  390. const toHome = () => {
  391. popupRef.value.close();
  392. uni.switchTab({
  393. url: "/pages/index/index",
  394. });
  395. };
  396. // async function onSelect({ type, data }) {
  397. // console.log(data,'data')
  398. // let msg = '';
  399. // const { data } = await sheep.$api.app.upload(data.tempFiles[0].path, 'default');
  400. // msg = {
  401. // from: 'customer',
  402. // mode: 'image',
  403. // date: new Date().getTime(),
  404. // content: {
  405. // url: fullurl,
  406. // path: path,
  407. // },
  408. // };
  409. // console.log(msg)
  410. // // if (msg) {
  411. // // socketSendMsg(msg, () => {
  412. // // scrollBottom();
  413. // // });
  414. // // // scrollBottom();
  415. // // chat.showTools = false;
  416. // // chat.showSelect = false;
  417. // // chat.selectMode = '';
  418. // // }
  419. // }
  420. // 查看协议
  421. function onProtocol(id, title, key) {
  422. sheep.$router.go("/pages/public/richtext", {
  423. id,
  424. title,
  425. key,
  426. });
  427. }
  428. // 注册
  429. const registerRef = ref(null);
  430. const toRegister = async () => {
  431. if (!protocol.value) {
  432. sheep.$helper.toast("请先阅读并勾选协议");
  433. return;
  434. }
  435. const validate = await unref(registerRef)
  436. .validate()
  437. .catch((error) => {
  438. console.log("error: ", error);
  439. });
  440. if (!validate) return;
  441. if (state.images.length == 0) {
  442. return sheep.$helper.toast("请上传门头照片");
  443. }
  444. let params = {
  445. ...state.model,
  446. picture: state.images.toString(),
  447. };
  448. sheep.$api.user
  449. .addShopRegistration(params)
  450. .then((res) => {
  451. console.log(res, "res");
  452. if (res.code == 200) {
  453. // registerScuShow.value = true
  454. popupRef.value.open("center");
  455. } else {
  456. sheep.$helper.toast(res.msg);
  457. }
  458. })
  459. .catch((err) => {
  460. sheep.$helper.toast(res.msg);
  461. });
  462. };
  463. </script>
  464. <style lang="scss" scoped>
  465. .picker-view {
  466. height: 400rpx;
  467. margin-top: 20rpx;
  468. }
  469. .item {
  470. line-height: 34px;
  471. text-align: center;
  472. }
  473. .content-block {
  474. padding: 0 60rpx;
  475. }
  476. ::v-deep .is-disabled {
  477. color: #333;
  478. }
  479. .icon {
  480. width: 199rpx;
  481. height: 199rpx;
  482. }
  483. .toLoginBtn {
  484. height: 88rpx;
  485. background: #f39801;
  486. border-radius: 16rpx;
  487. color: #fff;
  488. margin-bottom: 32rpx;
  489. margin-top: 30rpx;
  490. }
  491. .agreement-box {
  492. .tcp-text {
  493. color: #f49700;
  494. }
  495. .agreement-text {
  496. color: #adb5bd;
  497. font-size: 24rpx;
  498. }
  499. .isAgreement {
  500. color: #333;
  501. }
  502. }
  503. .safe-box {
  504. width: 100%;
  505. height: calc(constant(safe-area-inset-bottom) / 5 * 3);
  506. height: calc(env(safe-area-inset-bottom) / 5 * 3);
  507. }
  508. .popup-box {
  509. width: 590rpx;
  510. padding: 40rpx;
  511. .scuss-img {
  512. width: 240rpx;
  513. height: 240rpx;
  514. }
  515. .scuss-text {
  516. color: #17191c;
  517. text-align: center;
  518. font-size: 28rpx;
  519. font-weight: bold;
  520. margin: 10rpx 0 28rpx;
  521. padding: 0 28rpx;
  522. }
  523. .toHomeBtn {
  524. height: 80rpx;
  525. background: #f39801;
  526. border-radius: 16rpx;
  527. color: #fff;
  528. font-size: 32rpx;
  529. }
  530. }
  531. .right-box {
  532. height: 100%;
  533. }
  534. </style>