shopInfo.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <!-- #ifdef MP-WEIXIN -->
  3. <uv-navbar
  4. :fixed="false"
  5. :title="title"
  6. left-arrow
  7. @leftClick="$onClickLeft"
  8. />
  9. <!-- #endif -->
  10. <view style="padding-bottom: 120rpx;" class="p-3">
  11. <view class="card">
  12. <view class="card_item flex content-center">
  13. <view class="left">
  14. 店铺名称
  15. </view>
  16. <input class="right" v-model="formData.name" type="text" placeholder="请输入">
  17. </view>
  18. <view class="card_item flex content-center">
  19. <view class="left">
  20. 店铺电话
  21. </view>
  22. <input class="right" v-model="formData.mobile" type="text" placeholder="请输入">
  23. </view>
  24. <view class="card_item flex content-center">
  25. <view class="left">
  26. 地图地址
  27. </view>
  28. <view class="input" @click="chooseLocation">{{formData.addressMap ? formData.addressMap : '请选择地址'}}</view>
  29. </view>
  30. <view class="card_item flex content-center">
  31. <view class="left">
  32. 详细地址
  33. </view>
  34. <input class="right" v-model="formData.address" type="text" placeholder="请输入">
  35. </view>
  36. </view>
  37. <view class="card_thr">
  38. <view class="card_item flex content-center justify-between line">
  39. <view class="left">
  40. 营业开始时间
  41. </view>
  42. <view class="flex content-center" @click="setShow(1)">
  43. {{formatDateTime(formData.startTime,'hh:mm:ss') || '请选择'}}
  44. <uv-icon name="arrow-right" size="20"></uv-icon>
  45. </view>
  46. </view>
  47. <view class="card_item flex content-center justify-between">
  48. <view class="left">
  49. 营业结束时间
  50. </view>
  51. <view class="flex content-center" @click="setShow(2)">
  52. {{formatDateTime(formData.endTime,'hh:mm:ss') || '请选择'}}
  53. <uv-icon name="arrow-right" size="20"></uv-icon>
  54. </view>
  55. </view>
  56. </view>
  57. <uv-datetime-picker ref="datetimePicker" @confirm='confirm' v-model="value1" mode="time">
  58. </uv-datetime-picker>
  59. <view class="fixed">
  60. <view class="btn" @click="update">
  61. 保存
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script setup>
  67. import {
  68. ref
  69. } from 'vue'
  70. import {
  71. updateShop
  72. } from '@/api/merchant'
  73. import { onLoad} from '@dcloudio/uni-app'
  74. import { useMainStore } from '@/store/store'
  75. import { storeToRefs } from 'pinia'
  76. import { formatDateTime } from '@/utils/util'
  77. const main = useMainStore()
  78. const { merchartShop } = storeToRefs(main)
  79. const title = ref('店铺资料')
  80. const datetimePicker = ref()
  81. const index = ref(0)
  82. const value1 = ref(formatDateTime(new Date()))
  83. const formData = ref({
  84. id: merchartShop.value.id,
  85. name: merchartShop.value.name,
  86. mobile: merchartShop.value.mobile,
  87. addressMap: merchartShop.value.addressMap,
  88. address: merchartShop.value.address,
  89. startTime: merchartShop.value.startTime,
  90. endTime: merchartShop.value.endTime
  91. })
  92. const update = async() =>{
  93. let res = await updateShop(formData.value)
  94. if(res){
  95. main.SET_MERCHART_SHOP(res)
  96. uni.navigateBack()
  97. }
  98. }
  99. const setShow = (i) =>{
  100. datetimePicker.value.open()
  101. index.value = i
  102. }
  103. const confirm = (e) =>{
  104. let myTime = e.value.split(':')
  105. let now = new Date()
  106. let nowStr = formatDateTime(now,'yyyy-MM-dd')
  107. let newTime =nowStr + ' ' + e.value;
  108. if(index.value == 1){
  109. formData.value.startTime = new Date(newTime)
  110. }else{
  111. formData.value.endTime = new Date(newTime)
  112. }
  113. }
  114. const chooseLocation = async() => {
  115. uni.chooseLocation({
  116. success: function (res) {
  117. formData.value.addressMap = res.address + ' ' + res.name;
  118. formData.value.lat= res.latitude;
  119. formData.value.lng = res.longitude;
  120. },
  121. fail: function(res1) {
  122. },
  123. complete: function(res2) {
  124. },
  125. });
  126. }
  127. </script>
  128. <style lang="scss">
  129. .mlimg {
  130. width: 479rpx;
  131. height: 280rpx;
  132. }
  133. .fixed {
  134. position: fixed;
  135. bottom: 0;
  136. left: 0;
  137. right: 0;
  138. background-color: #fff;
  139. height: 120rpx;
  140. .btn {
  141. width: 700rpx;
  142. height: 98rpx;
  143. background: #059825;
  144. border-radius: 14rpx;
  145. margin: 0 auto;
  146. line-height: 98rpx;
  147. text-align: center;
  148. font-size: 32rpx;
  149. color: #FFFFFF;
  150. }
  151. }
  152. .card {
  153. padding: 20rpx 40rpx;
  154. box-sizing: border-box;
  155. background-color: #fff;
  156. .title {
  157. width: 620rpx;
  158. height: 64rpx;
  159. background: #A0E0FF;
  160. border-radius: 10rpx;
  161. text-align: center;
  162. font-size: 24rpx;
  163. color: #0097E1;
  164. line-height: 64rpx;
  165. }
  166. .card_item {
  167. padding: 34rpx 0;
  168. box-sizing: border-box;
  169. border-bottom: 1rpx solid #f5f5f5;
  170. .left {
  171. font-size: 28rpx;
  172. color: #333333;
  173. width: 140rpx;
  174. }
  175. .yzm {
  176. width: 300rpx;
  177. }
  178. .btn {
  179. width: 158rpx;
  180. height: 50rpx;
  181. background: #FFFFFF;
  182. border-radius: 25rpx;
  183. border: 2rpx solid #0CAFFE;
  184. font-size: 24rpx;
  185. color: #0CAFFE;
  186. text-align: center;
  187. line-height: 50rpx;
  188. margin-top: -10rpx;
  189. margin-left: 20rpx;
  190. }
  191. }
  192. }
  193. .card_thr {
  194. padding: 20rpx 40rpx;
  195. box-sizing: border-box;
  196. background-color: #fff;
  197. .card_item {
  198. padding: 34rpx 0;
  199. box-sizing: border-box;
  200. .left {
  201. font-size: 28rpx;
  202. color: #333333;
  203. }
  204. }
  205. }
  206. .line {
  207. border-bottom: 1rpx solid #f5f5f5;
  208. }
  209. </style>