apply.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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="number" />
  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.sync="showRegion" @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, sendSmsW, 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. showRegion: false,
  92. // 省市联动
  93. regionData: [],
  94. cityPickerValueDefault: [0, 0],
  95. // 验证码
  96. isSend: 0,
  97. countDown: 59,
  98. timer: null
  99. }
  100. },
  101. onLoad() {
  102. // if (!this.$util.isLogin()) {
  103. // // getShopUser()
  104. // return false
  105. // }
  106. // this.init()
  107. },
  108. methods: {
  109. init() {
  110. this.$util.getCheckLogin().then(res => {
  111. if (res) {
  112. let id = this.option.merchantId
  113. if (id) {
  114. this._getMerchantDet()
  115. }
  116. this._regionTree()
  117. }
  118. })
  119. },
  120. _regionTree() {
  121. regionTreeW().then(res => {
  122. this.regionData = res.data.tree
  123. })
  124. },
  125. _getMerchantDet() {
  126. merchantDet({ id: this.option.merchantId }).then(res => {
  127. this.merchantData = res.data
  128. })
  129. },
  130. // ==============
  131. confirmFn() {
  132. applyRegister({
  133. oldId: this.option.merchantId || 0,
  134. ...this.form
  135. }).then(res => {
  136. this.$util.pageTo({
  137. // url: '/official/pay',
  138. url: '/official/callback',
  139. type: 2,
  140. query: {
  141. pagestatus: 3
  142. // orderSn: this.option.orderSn,
  143. // payDiscountPrice: res.data.discountAmount
  144. }
  145. })
  146. })
  147. },
  148. // 验证码
  149. getCode() {
  150. if (!this.form.mobile || !this.$util.checkMobile(this.form.mobile)) {
  151. this.$msg('请输入正确的手机号!')
  152. return false
  153. }
  154. this.isSend = 1
  155. sendSms({
  156. type: 1,
  157. mobile: this.form.mobile
  158. })
  159. .then(res => {
  160. this.beginCountDown()
  161. this.$msg('发送成功!')
  162. })
  163. .catch(() => {
  164. this.isSend = 0
  165. this.$msg('发送失败!')
  166. })
  167. },
  168. // 倒计时
  169. beginCountDown() {
  170. this.countDown = 59
  171. this.timer = setInterval(() => {
  172. if (this.countDown === 0) {
  173. clearInterval(this.timer)
  174. this.isSend = 0
  175. return
  176. }
  177. this.countDown -= 1
  178. }, 1000)
  179. },
  180. // 选择地址
  181. selRegionFn() {
  182. if (!this.form.city) {
  183. this.$msg('请先选择地址!')
  184. return false
  185. }
  186. this.showRegion = true
  187. // let that = this
  188. // uni.chooseLocation({
  189. // success: (res) => {
  190. // this.form.address = res.address
  191. // this.form.latitude = res.latitude
  192. // this.form.longitude = res.longitude
  193. // console.log('位置名称:' + res.name)
  194. // console.log('详细地址:' + res.address)
  195. // console.log('纬度:' + res.latitude)
  196. // console.log('经度:' + res.longitude)
  197. // }
  198. // })
  199. },
  200. changeAreaFn(e) {
  201. console.log('changeAreaFn', e)
  202. this.form.address = e.address
  203. this.form.latitude = e.location.lat
  204. this.form.longitude = e.location.lng
  205. },
  206. // -----
  207. // 省市联动
  208. openAddres() {
  209. this.$refs.simpleAddress.open()
  210. },
  211. onCityConfirm(e) {
  212. // this.form.receiveAddress = e.label
  213. this.form.province = e.provinceName
  214. this.form.city = e.cityName
  215. // this.pickerText = JSON.stringify(e)
  216. },
  217. // 表单验证
  218. formSubmit(e) {
  219. // 表单规则
  220. let rules = []
  221. // 进行表单检查
  222. let formData = e.detail.value
  223. let checkRes = form.validation(formData, rules)
  224. // 验证通过!
  225. if (!checkRes) {
  226. setTimeout(() => {
  227. this.confirmFn()
  228. })
  229. } else {
  230. this.$msg(checkRes)
  231. }
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .module-com {
  238. margin-bottom: 20px;
  239. background-color: #fff;
  240. .module-tit {
  241. padding: 20px 18px;
  242. font-size: 28px;
  243. font-weight: 600;
  244. border-bottom: 1px solid $borderColor;
  245. }
  246. .module-det {
  247. padding: 0 30px;
  248. }
  249. }
  250. // 公共
  251. .line-cell {
  252. .tui-title {
  253. width: 210px;
  254. color: $fontColor2;
  255. }
  256. .tui-input {
  257. width: calc(100% - 210px);
  258. font-size: 28px;
  259. }
  260. .tui-placeholder {
  261. color: #ccc;
  262. }
  263. .phcolor {
  264. color: #ccc;
  265. }
  266. }
  267. .btn-wrap {
  268. width: 90%;
  269. margin: 60px auto;
  270. .admin-button-com {
  271. width: 100%;
  272. margin: 0 auto;
  273. }
  274. }
  275. // 验证码
  276. .code-wrap {
  277. .tui-input {
  278. width: calc(100% - 410px);
  279. font-size: 28px;
  280. }
  281. .tui-code {
  282. width: 200px;
  283. text-align: center;
  284. border-left: 1px solid $borderColor;
  285. color: $mainColor;
  286. }
  287. }
  288. // 推荐人
  289. .recommend-wrap {
  290. padding: 30px 45px;
  291. .recommend-tag {
  292. font-size: 28px;
  293. color: $fontColor2;
  294. margin-bottom: 24px;
  295. }
  296. .recommend-det {
  297. @include disFlex(center, flex-start);
  298. .recommend-info {
  299. margin-left: 20px;
  300. .app-size-32 {
  301. margin-bottom: 4px;
  302. }
  303. }
  304. }
  305. }
  306. </style>