pointManage.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view class="content">
  3. <view class="row b-b">
  4. <text class="tit">自提点名称</text>
  5. <input class="input" type="text" v-model="name" placeholder="请请填写自提点名称" placeholder-class="placeholder" />
  6. </view>
  7. <view class="row b-b">
  8. <text class="tit">联系电话</text>
  9. <input class="input" type="number" v-model="phone" placeholder="请填写联系电话" placeholder-class="placeholder" />
  10. </view>
  11. <view class="row b-b">
  12. <text class="tit">自提点地址</text>
  13. <pickerAddress class="input" @change="onCityClick">{{ address || '请选择自提地址' }}</pickerAddress>
  14. <text class="iconfont iconlocation"></text>
  15. </view>
  16. <view class="row b-b">
  17. <text class="tit">详细地址</text>
  18. <input class="input" type="text" v-model="detailed_address" placeholder="请填写详细地址" placeholder-class="placeholder" />
  19. </view>
  20. <view class="row b-b" @click="chooseLocation">
  21. <text class="tit">经纬度</text>
  22. <input class="input" type="text" v-model="latlng" placeholder="请输入经纬度" placeholder-class="placeholder" />
  23. </view>
  24. <view class="row b-b">
  25. <text class="tit">营业开始时间</text>
  26. <picker mode="time" :value="time" @change="bindBgTimeChange" class="input">
  27. <view class="uni-input">{{ bgTime }}</view>
  28. </picker>
  29. </view>
  30. <view class="row b-b">
  31. <text class="tit">营业结束时间</text>
  32. <picker mode="time" :value="time" @change="bindEdTimeChange" class="input">
  33. <view class="uni-input">{{ edTime }}</view>
  34. </picker>
  35. </view>
  36. <uni-list class="margin-t-20">
  37. <uni-list-item title="是否显示" :switch-checked="show" :show-switch="true" :show-arrow="false" switch-color="#921a23" @switchChange="switchChange"></uni-list-item>
  38. </uni-list>
  39. <view class="del-btn" v-if="showDel"><text @click="delAddr">删除地址</text></view>
  40. <button class="add-btn" @click="confirm">提交</button>
  41. </view>
  42. </template>
  43. <script>
  44. import uniList from '@/components/uni-list/uni-list.vue';
  45. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  46. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  47. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  48. import { addressEdit, editPoint } from '@/api/user.js';
  49. export default {
  50. components: {
  51. uniList,
  52. uniListItem,
  53. pickerAddress,
  54. uniPopup
  55. },
  56. data() {
  57. return {
  58. name: '', //自提点名称
  59. phone: '', //自提点电话
  60. show: true, //是否显示
  61. addressDetail: '',
  62. showDel: false,
  63. latlng: '',
  64. detailed_address: '', //用户自填详细字段
  65. address: '', //【省、市、区】
  66. point_id: 0, //自提点id
  67. bgTime: '00:00', //自提点开始营业时间
  68. edTime: '00:00', //自提点结束营业时间
  69. time: '00:00',
  70. timeOptions: [
  71. ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'],
  72. ['00', '05', '10', '15', '20', '25', '30', '35', '40', '45', '50', '55']
  73. ]
  74. };
  75. },
  76. onLoad(option) {
  77. let title = '新增自提点';
  78. if (option.type === 'edit') {
  79. title = '编辑自提点';
  80. let data = JSON.parse(option.data);
  81. console.log(data);
  82. this.name = data.name;
  83. this.show = data.is_show == 1 ? true : false;
  84. this.latlng = data.latitude + ',' + data.longitude;
  85. this.detailed_address = data.detailed_address;
  86. this.address = data.address;
  87. this.phone = data.phone;
  88. this.point_id = data.id;
  89. let time = data.day_time
  90. let arr = time.split(' - ')
  91. this.bgTime = arr[0].slice(0,5)
  92. this.edTime = arr[1].slice(0,5)
  93. console.log(arr,'arr++++++++++++++++++++++++')
  94. }
  95. this.manageType = option.type;
  96. uni.setNavigationBarTitle({
  97. title
  98. });
  99. },
  100. methods: {
  101. // 选中城市切换
  102. onCityClick({ data }) {
  103. // let address = this.detailed_address;
  104. let province = data[0];
  105. let city = data[1];
  106. let district = data[2];
  107. this.address = province + ',' + city + ',' + district;
  108. },
  109. //地图选择地址
  110. chooseLocation() {
  111. uni.chooseLocation({
  112. success: res => {
  113. console.log('纬度:' + res.latitude);
  114. console.log('经度:' + res.longitude);
  115. this.latlng = res.latitude + ',' + res.longitude;
  116. }
  117. });
  118. },
  119. // 设置是否为显示
  120. switchChange(e) {
  121. this.show = e.value;
  122. },
  123. //提交
  124. confirm() {
  125. let obj = this;
  126. if (!obj.name) {
  127. this.$api.msg('请填写自提点名称');
  128. return;
  129. }
  130. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(obj.phone)) {
  131. this.$api.msg('请输入正确的手机号码');
  132. return;
  133. }
  134. if (!obj.address) {
  135. this.$api.msg('请选择地址');
  136. return;
  137. }
  138. if (!obj.latlng) {
  139. this.$api.msg('请输入经纬度');
  140. return;
  141. }
  142. let bgH = obj.bgTime.slice(0,2)*1
  143. let edH = obj.edTime.slice(0,2)*1
  144. // if(bgH > edH) {
  145. // this.$api.msg('请输入正确的经营时间')
  146. // return
  147. // }else if( bgH == edH) {
  148. // let bgM = obj.bgTime.slice(3,5)*1
  149. // let edM = obj.edTime.slice(3,5)*1
  150. // if(bgM > edM) {
  151. // this.$api.msg('请输入正确的经营时间')
  152. // return
  153. // }
  154. // }
  155. uni.showLoading({
  156. title: '提交中...',
  157. mask: true
  158. })
  159. //this.$api.prePage()获取上一页实例,可直接调用上页所有数据和方法,在App.vue定义
  160. editPoint(
  161. {
  162. name: obj.name,
  163. phone: obj.phone,
  164. address: obj.address.split(','),
  165. detailed_address: obj.detailed_address,
  166. latlng: obj.latlng,
  167. is_show: obj.show ? 1 : 0,
  168. day_time: [obj.bgTime+':00',obj.edTime+':00']
  169. },
  170. obj.point_id
  171. ).then(function(e) {
  172. uni.hideLoading()
  173. obj.$api.prePage().refreshList();
  174. uni.showToast({
  175. title: '提交成功',
  176. duration: 2000
  177. });
  178. setTimeout(function() {
  179. uni.navigateBack();
  180. }, 800);
  181. })
  182. },
  183. bindBgTimeChange(e) {
  184. console.log(e,'shijian')
  185. this.bgTime = e.detail.value
  186. },
  187. bindEdTimeChange(e) {
  188. this.edTime = e.detail.value
  189. }
  190. }
  191. };
  192. </script>
  193. <style lang="scss">
  194. page {
  195. background: $page-color-base;
  196. padding-top: 16rpx;
  197. }
  198. .row {
  199. display: flex;
  200. align-items: center;
  201. position: relative;
  202. padding: 0 30rpx;
  203. height: 110rpx;
  204. background: #fff;
  205. .tit {
  206. flex-shrink: 0;
  207. width: 300rpx;
  208. font-size: 30rpx;
  209. color: $font-color-dark;
  210. }
  211. .input {
  212. flex: 1;
  213. font-size: 30rpx;
  214. color: $font-color-dark;
  215. }
  216. .iconlocation {
  217. font-size: 36rpx;
  218. color: $font-color-light;
  219. }
  220. }
  221. .default-row {
  222. margin-top: 16rpx;
  223. .tit {
  224. flex: 1;
  225. }
  226. switch {
  227. transform: translateX(16rpx) scale(0.9);
  228. }
  229. }
  230. .del-btn {
  231. width: 750rpx;
  232. height: 99rpx;
  233. margin-top: 28rpx;
  234. font-size: 30rpx;
  235. font-weight: 500;
  236. color: #901b21;
  237. background-color: #fff;
  238. line-height: 99rpx;
  239. padding-left: 42rpx;
  240. }
  241. .add-btn {
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. width: 690rpx;
  246. height: 80rpx;
  247. margin: 60rpx auto;
  248. font-size: $font-lg;
  249. color: #fff;
  250. background-color: $base-color;
  251. border-radius: 10rpx;
  252. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  253. }
  254. .alert-box {
  255. background-color: #ffffff;
  256. }
  257. </style>