推拿小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
8.1 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="商家合作" leftClick @leftClick="$utils.navigateBack" color="#fff" />
  5. <view v-if="['0', '2'].includes(status) && statusDesc" class="flex tips">
  6. <uv-icon name="info-circle" color="#86A941" size="28rpx"></uv-icon>
  7. <text style="margin-left: 3rpx;">{{ statusDesc }}</text>
  8. </view>
  9. <view class="content">
  10. <view class="form">
  11. <view class="form-title">门头照片</view>
  12. <view class="card upload">
  13. <formUpload v-model="form.image">
  14. <template v-slot="{ value }">
  15. <view class="flex">
  16. <image v-if="value" class="upload-img" :src="value" mode="aspectFill" />
  17. <image v-else class="upload-img" src="../static/cooperation/icon-upload.png"
  18. mode="aspectFill" />
  19. </view>
  20. </template>
  21. </formUpload>
  22. </view>
  23. </view>
  24. <view class="form">
  25. <view class="form-title">店铺信息</view>
  26. <view class="card info">
  27. <uv-form ref="form" :model="form" :rules="rules" labelPosition="left" labelWidth="150rpx"
  28. :labelStyle="{
  29. color: '#000000',
  30. fontSize: '28rpx',
  31. }">
  32. <view class="form-item">
  33. <uv-form-item label="店铺名称" prop="shop">
  34. <view class="form-item-content">
  35. <formInput v-model="form.shop" placeholder="请输入店铺名称"></formInput>
  36. </view>
  37. </uv-form-item>
  38. </view>
  39. <view class="form-item">
  40. <uv-form-item label="您的姓名" prop="name">
  41. <view class="form-item-content">
  42. <formInput v-model="form.name" placeholder="请输入您的姓名"></formInput>
  43. </view>
  44. </uv-form-item>
  45. </view>
  46. <view class="form-item">
  47. <uv-form-item label="联系手机号" prop="phone">
  48. <view class="form-item-content">
  49. <formInput v-model="form.phone" placeholder="请输入您的手机号"></formInput>
  50. </view>
  51. </uv-form-item>
  52. </view>
  53. <view class="form-item">
  54. <uv-form-item label="所在地区" prop="area">
  55. <view class="form-item-content flex area">
  56. <view style="width: 450rpx;">{{ form.area ? form.area : '请选择' }}</view>
  57. <button plain class="btn area-btn" @click="selectAddr">
  58. <image class="area-btn-icon" src="../static/cooperation/icon-arrow.png"
  59. mode="widthFix"></image>
  60. </button>
  61. </view>
  62. </uv-form-item>
  63. </view>
  64. <view class="form-item address">
  65. <uv-form-item label="详细地址" prop="address" labelPosition="top">
  66. <view style="margin-top: 22rpx;width: 100%;">
  67. <formTextarea v-model="form.address" placeholder="请输入详细地址"></formTextarea>
  68. </view>
  69. </uv-form-item>
  70. </view>
  71. </uv-form>
  72. </view>
  73. </view>
  74. <view class="tools" v-if="status != '1'">
  75. <button plain class="btn btn-submit" @click="onSubmit">提交</button>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import {
  82. mapState
  83. } from 'vuex'
  84. import Position from '@/utils/position.js'
  85. import formInput from '../components/formInput.vue'
  86. import formUpload from '../components/formUpload.vue'
  87. import formTextarea from '../components/formTextarea.vue'
  88. export default {
  89. components: {
  90. formInput,
  91. formUpload,
  92. formTextarea,
  93. },
  94. data() {
  95. return {
  96. id: null,
  97. status: null,
  98. statusDesc: null,
  99. form: {
  100. image: null,
  101. shop: null,
  102. name: null,
  103. phone: null,
  104. area: null,
  105. latitude: null,
  106. longitude: null,
  107. address: null,
  108. },
  109. rules: {
  110. 'image': {
  111. type: 'string',
  112. required: true,
  113. message: '请选择门头照片',
  114. },
  115. 'shop': {
  116. type: 'string',
  117. required: true,
  118. message: '请输入店铺名称',
  119. },
  120. 'name': {
  121. type: 'string',
  122. required: true,
  123. message: '请输入您的姓名',
  124. },
  125. 'phone': {
  126. type: 'string',
  127. required: true,
  128. message: '请输入您的手机号',
  129. },
  130. 'area': {
  131. type: 'string',
  132. required: true,
  133. message: '请选择所在地区',
  134. },
  135. 'address': {
  136. type: 'string',
  137. required: true,
  138. message: '请输入详细地址',
  139. },
  140. },
  141. }
  142. },
  143. computed: {
  144. ...mapState(['userInfo']),
  145. },
  146. onLoad() {
  147. this.initData()
  148. },
  149. onPullDownRefresh() {
  150. this.updateStatus()
  151. },
  152. methods: {
  153. //地图上选择地址
  154. selectAddr() {
  155. // Position.getLocation(res => {
  156. Position.selectAddress(0, 0, success => {
  157. this.setAddress(success)
  158. })
  159. // })
  160. },
  161. //提取用户选择的地址信息复制给表单数据
  162. setAddress(res) {
  163. //经纬度信息
  164. this.form.latitude = res.latitude
  165. this.form.longitude = res.longitude
  166. if (!res.address && res.name) { //用户直接选择城市的逻辑
  167. return this.form.area = res.name
  168. }
  169. if (res.address || res.name) {
  170. return this.form.area = res.address + res.name
  171. }
  172. this.form.area = '' //用户啥都没选就点击勾选
  173. },
  174. async initData() {
  175. try {
  176. const shopDetails = (await this.$fetch('queryShopById'))
  177. console.log("shopDetails======")
  178. console.log(shopDetails)
  179. if (!shopDetails) {
  180. return
  181. }
  182. const {
  183. id,
  184. status,
  185. status_dictText,
  186. remark,
  187. image,
  188. shop,
  189. name,
  190. phone,
  191. area,
  192. latitude,
  193. longitude,
  194. address,
  195. } = shopDetails
  196. this.form = {
  197. image,
  198. shop,
  199. name,
  200. phone,
  201. area,
  202. latitude,
  203. longitude,
  204. address,
  205. }
  206. this.id = id
  207. this.status = status
  208. this.statusDesc = status == '2' ? `${status_dictText}${remark}` : status_dictText
  209. } catch (err) {
  210. }
  211. },
  212. async updateStatus() {
  213. if (!this.id) {
  214. return
  215. }
  216. try {
  217. const {
  218. status,
  219. status_dictText,
  220. remark
  221. } = await this.$fetch('queryShopById', {
  222. id: this.id
  223. })
  224. this.status = status
  225. this.statusDesc = status == '2' ? `${status_dictText}${remark}` : status_dictText
  226. } catch (err) {
  227. console.log('--err', err)
  228. }
  229. uni.stopPullDownRefresh();
  230. },
  231. async onSubmit() {
  232. try {
  233. await this.$refs.form.validate()
  234. const {
  235. image,
  236. shop,
  237. name,
  238. phone,
  239. area,
  240. latitude,
  241. longitude,
  242. address,
  243. } = this.form
  244. const params = {
  245. image,
  246. shop,
  247. name,
  248. phone,
  249. area,
  250. latitude,
  251. longitude,
  252. address,
  253. }
  254. let api = this.id ? 'updateShop' : 'addShop'
  255. await this.$fetch(api, params)
  256. uni.showToast({
  257. title: '提交成功',
  258. icon: 'none'
  259. })
  260. setTimeout(uni.navigateBack, 1000, -1)
  261. } catch (err) {
  262. }
  263. },
  264. },
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .page {
  269. background-color: $uni-bg-color;
  270. min-height: 100vh;
  271. /deep/ .nav-bar__view {
  272. background-image: linear-gradient(#84A73F, #D8FF8F);
  273. }
  274. }
  275. .tips {
  276. padding: 5rpx 0;
  277. font-weight: bold;
  278. font-size: 28rpx;
  279. color: $uni-color;
  280. background-color: rgba($color: #D8FF8F, $alpha: 0.3);
  281. }
  282. .content {
  283. padding: 28rpx 30rpx;
  284. }
  285. .form {
  286. &+& {
  287. margin-top: 44rpx;
  288. }
  289. &-title {
  290. color: #000000;
  291. font-size: 28rpx;
  292. margin-bottom: 15rpx;
  293. }
  294. &-item {
  295. padding-left: 8rpx;
  296. &+& {
  297. // margin-top: 20rpx;
  298. border-top: 1rpx solid rgba($color: #C7C7C7, $alpha: 0.69);
  299. }
  300. &-content {
  301. min-height: 60rpx;
  302. display: flex;
  303. align-items: center;
  304. justify-content: flex-end;
  305. font-size: 28rpx;
  306. ;
  307. color: #999999;
  308. }
  309. }
  310. }
  311. .upload {
  312. padding: 37rpx 22rpx;
  313. &-img {
  314. width: 131rpx;
  315. height: 131rpx;
  316. }
  317. }
  318. .area {
  319. color: #000000;
  320. font-size: 28rpx;
  321. line-height: 40rpx;
  322. justify-content: flex-end;
  323. &-btn {
  324. border: none;
  325. padding: 7rpx 20rpx 7rpx 7rpx;
  326. &-icon {
  327. width: 30rpx;
  328. height: auto;
  329. }
  330. }
  331. }
  332. .address {
  333. padding: 0;
  334. /deep/ .uv-form-item__body__left__content {
  335. margin-top: 10rpx;
  336. padding-left: 8rpx;
  337. }
  338. }
  339. .tools {
  340. padding: 0 56rpx;
  341. margin-top: 126rpx;
  342. }
  343. .btn-submit {
  344. padding: 29rpx 0;
  345. border: none;
  346. font-size: 36rpx;
  347. border-radius: 45rpx;
  348. color: $uni-text-color-inverse;
  349. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  350. }
  351. </style>