apply.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div class="app-content">
  3. <form @submit="formSubmit">
  4. <div class="module-com">
  5. <tui-list-cell class="line-cell" :hover="false">
  6. <div class="tui-title">花店名称</div>
  7. <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请输入姓名" />
  8. </tui-list-cell>
  9. <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="openAddres">
  10. <div class="tui-title">花店地址</div>
  11. <div class="tui-input" v-if="form.province">{{ form.province + '-' + form.city }}</div>
  12. <div class="tui-placeholder" v-else>请选择</div>
  13. </tui-list-cell>
  14. <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="selRegionFn">
  15. <div class="tui-title">详细地址</div>
  16. <div class="tui-input" v-if="form.address">{{ form.address }}</div>
  17. <div class="tui-placeholder" v-else>请选择详细地址</div>
  18. </tui-list-cell>
  19. <tui-list-cell class="line-cell" :hover="false">
  20. <div class="tui-title">门牌号</div>
  21. <input v-model="form.floor" placeholder-class="phcolor" class="tui-input" name="floor" placeholder="楼号门牌号,如23号403室 (选填)" />
  22. </tui-list-cell>
  23. </div>
  24. <!-- 手机号 -->
  25. <div class="module-com">
  26. <tui-list-cell class="line-cell" :hover="false">
  27. <div class="tui-title">手机号</div>
  28. <input v-model="form.mobile" placeholder-class="phcolor" class="tui-input" name="mobile" placeholder="请输入" type="phone" />
  29. </tui-list-cell>
  30. <tui-list-cell class="line-cell code-wrap" :hover="false">
  31. <div class="tui-title">验证码</div>
  32. <input v-model="form.code" placeholder-class="phcolor" class="tui-input" name="code" placeholder="请输入验证码" type="number" />
  33. <div class="tui-code" v-if="isSend">{{ countDown + 's' }}</div>
  34. <div class="tui-code" v-else @click="getCode">获取验证码</div>
  35. </tui-list-cell>
  36. </div>
  37. <!-- 推荐人 -->
  38. <div class="module-com recommend-wrap" v-if="!$util.isEmpty(merchantData)">
  39. <div class="recommend-tag">推荐人</div>
  40. <div class="recommend-det">
  41. <app-avatar-module :src="merchantData.smallLogoUrl" :width="78" alt="推荐人头像" />
  42. <div class="recommend-info">
  43. <div class="app-size-32">{{ merchantData.merchantName }}</div>
  44. <div class="app-color-2">{{ merchantData.address }}</div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="btn-wrap">
  49. <button class="admin-button-com blue big" formType="submit">确认</button>
  50. </div>
  51. <!-- 选择地区 -->
  52. <!-- <app-area-sel :show="showRegion" @hide="hideAreaSel" @change="changeAreaFn" /> -->
  53. <!-- 省市联动 -->
  54. <simple-address ref="simpleAddress" :region="regionData" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onCityConfirm"></simple-address>
  55. </form>
  56. </div>
  57. </template>
  58. <script>
  59. import TuiListCell from '@/components/plugin/list-cell'
  60. // import AppAreaSel from '@/components/app-area-sel'
  61. import SimpleAddress from '@/components/plugin/simple-address'
  62. import AppAvatarModule from '@/components/module/app-avatar'
  63. const form = require('@/utils/formValidation.js')
  64. // api
  65. import { merchantDet, applyRegister, sendSms, regionTreeW } from '@/api/official'
  66. import { getShopUser } from '@/utils/auth'
  67. export default {
  68. name: 'apply-data',
  69. components: {
  70. TuiListCell,
  71. // AppAreaSel,
  72. SimpleAddress,
  73. AppAvatarModule
  74. },
  75. data() {
  76. return {
  77. merchantData: {},
  78. form: {
  79. name: '',
  80. mobile: '',
  81. province: '',
  82. city: '',
  83. dist: '',
  84. address: '',
  85. floor: '',
  86. longitude: '',
  87. latitude: ''
  88. // 推荐商家id
  89. // oldId: ''
  90. },
  91. // 省市联动
  92. regionData: [],
  93. cityPickerValueDefault: [0, 0],
  94. // 验证码
  95. isSend: 0,
  96. countDown: 59,
  97. timer: null
  98. }
  99. },
  100. onLoad() {
  101. let token = uni.getStorageSync('token')
  102. if (!token) {
  103. getShopUser()
  104. return false
  105. }
  106. this.init()
  107. },
  108. methods: {
  109. init() {
  110. let id = this.option.merchantId
  111. if (id) {
  112. this._getMerchantDet()
  113. }
  114. this._regionTree()
  115. },
  116. _regionTree() {
  117. regionTreeW().then(res => {
  118. this.regionData = res.data.tree
  119. })
  120. },
  121. _getMerchantDet() {
  122. merchantDet({ id: this.option.merchantId }).then(res => {
  123. this.merchantData = res.data
  124. })
  125. },
  126. // ==============
  127. confirmFn() {
  128. applyRegister({
  129. oldId: this.option.merchantId || 0,
  130. ...this.form
  131. }).then(res => {
  132. this.$util.pageTo({
  133. url: '/official/pay',
  134. type: 2,
  135. query: {
  136. pagestatus: 2,
  137. ...res.data
  138. }
  139. })
  140. })
  141. },
  142. // 验证码
  143. getCode() {
  144. if (!this.form.mobile || !this.$util.checkMobile(this.form.mobile)) {
  145. this.$msg('请输入正确的手机号!')
  146. return false
  147. }
  148. this.isSend = 1
  149. sendSms({
  150. type: 1,
  151. mobile: this.form.mobile
  152. })
  153. .then(res => {
  154. this.beginCountDown()
  155. this.$msg('发送成功!')
  156. })
  157. .catch(() => {
  158. this.isSend = 0
  159. this.$msg('发送失败!')
  160. })
  161. },
  162. // 倒计时
  163. beginCountDown() {
  164. this.countDown = 59
  165. this.timer = setInterval(() => {
  166. if (this.countDown === 0) {
  167. clearInterval(this.timer)
  168. this.isSend = 0
  169. return
  170. }
  171. this.countDown -= 1
  172. }, 1000)
  173. },
  174. // 选择地址
  175. selRegionFn() {
  176. let that = this
  177. uni.chooseLocation({
  178. success: (res) => {
  179. this.form.address = res.address
  180. this.form.latitude = res.latitude
  181. this.form.longitude = res.longitude
  182. console.log('位置名称:' + res.name)
  183. console.log('详细地址:' + res.address)
  184. console.log('纬度:' + res.latitude)
  185. console.log('经度:' + res.longitude)
  186. }
  187. })
  188. },
  189. // 省市联动
  190. openAddres() {
  191. this.$refs.simpleAddress.open()
  192. },
  193. onCityConfirm(e) {
  194. // this.form.receiveAddress = e.label
  195. this.form.province = e.provinceName
  196. this.form.city = e.cityName
  197. // this.pickerText = JSON.stringify(e)
  198. },
  199. // 表单验证
  200. formSubmit(e) {
  201. // 表单规则
  202. let rules = []
  203. // 进行表单检查
  204. let formData = e.detail.value
  205. let checkRes = form.validation(formData, rules)
  206. // 验证通过!
  207. if (!checkRes) {
  208. setTimeout(() => {
  209. this.confirmFn()
  210. })
  211. } else {
  212. this.$msg(checkRes)
  213. }
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .module-com {
  220. margin-bottom: 20px;
  221. background-color: #fff;
  222. .module-tit {
  223. padding: 20px 18px;
  224. font-size: 28px;
  225. font-weight: 600;
  226. border-bottom: 1px solid $borderColor;
  227. }
  228. .module-det {
  229. padding: 0 30px;
  230. }
  231. }
  232. // 公共
  233. .line-cell {
  234. .tui-title {
  235. width: 210px;
  236. color: $fontColor2;
  237. }
  238. .tui-input {
  239. width: calc(100% - 210px);
  240. font-size: 28px;
  241. }
  242. .tui-placeholder {
  243. color: #ccc;
  244. }
  245. .phcolor {
  246. color: #ccc;
  247. }
  248. }
  249. .btn-wrap {
  250. width: 90%;
  251. margin: 60px auto;
  252. .admin-button-com {
  253. width: 100%;
  254. margin: 0 auto;
  255. }
  256. }
  257. // 验证码
  258. .code-wrap {
  259. .tui-input {
  260. width: calc(100% - 410px);
  261. font-size: 28px;
  262. }
  263. .tui-code {
  264. width: 200px;
  265. text-align: center;
  266. border-left: 1px solid $borderColor;
  267. color: $mainColor;
  268. }
  269. }
  270. // 推荐人
  271. .recommend-wrap {
  272. padding: 30px 45px;
  273. .recommend-tag {
  274. font-size: 28px;
  275. color: $fontColor2;
  276. margin-bottom: 24px;
  277. }
  278. .recommend-det {
  279. @include disFlex(center, flex-start);
  280. .recommend-info {
  281. margin-left: 20px;
  282. .app-size-32 {
  283. margin-bottom: 4px;
  284. }
  285. }
  286. }
  287. }
  288. </style>