apply.vue 8.1 KB

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