shop.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <view class="item">
  5. <view class="item-tit">店铺名称:</view>
  6. <input type="text" v-model="storeName" placeholder="请输入店铺名称" />
  7. </view>
  8. <view class="item">
  9. <view class="item-tit">店铺简介:</view>
  10. <input type="text" v-model="storeinfo" placeholder="请输入店铺简介" />
  11. </view>
  12. </view>
  13. <view class="box">
  14. <view class="item">
  15. <view class="item-tit">姓名:</view>
  16. <input type="text" v-model="name" placeholder="请输入姓名" />
  17. </view>
  18. <view class="item">
  19. <view class="item-tit">手机号:</view>
  20. <input type="text" v-model="phone" placeholder="请输入手机号" />
  21. </view>
  22. <view class="item">
  23. <view class="item-tit">地址:</view>
  24. <pickerAddress class="input" @change="onCityClick">{{ addressDetail || '请选择地址' }}</pickerAddress>
  25. <!-- <text class="iconfont iconlocation"></text> -->
  26. </view>
  27. <view class="item">
  28. <view class="item-tit">详细地址:</view>
  29. <input type="text" v-model="detailed_address" placeholder="请输入详细地址" />
  30. </view>
  31. </view>
  32. <view class="sub" @click="sub" v-if="type == 'edit'">确认修改</view>
  33. <view class="sub" @click="add" v-if="type == 'add'">提交</view>
  34. </view>
  35. </template>
  36. <script>
  37. import { editStore } from '@/api/user.js';
  38. import { upload } from '@/api/order.js';
  39. import pickerAddress from '@/components/wangding-pickerAddress/wangding-pickerAddress.vue';
  40. export default {
  41. components: {
  42. pickerAddress
  43. },
  44. data() {
  45. return {
  46. type: 'add',
  47. storeName: '',
  48. storeinfo: '',
  49. name: '',
  50. phone: '',
  51. addressDetail: '',
  52. detailed_address: '',
  53. address: {
  54. province: '',
  55. city: '',
  56. district: ''
  57. }
  58. };
  59. },
  60. onLoad(opt) {},
  61. methods: {
  62. onCityClick({ data }) {
  63. let address = this.address;
  64. address.province = data[0];
  65. address.city = data[1];
  66. address.district = data[2];
  67. this.addressDetail = data.join('');
  68. },
  69. //提交
  70. sub() {
  71. let obj = this;
  72. if (obj.storeName == '') {
  73. obj.$api.msg('请输入店铺姓名');
  74. return;
  75. }
  76. if (obj.storeinfo == '') {
  77. obj.$api.msg('请输入店铺简介');
  78. return;
  79. }
  80. if (obj.name == '') {
  81. obj.$api.msg('请输入姓名');
  82. return;
  83. }
  84. if (obj.phone == '') {
  85. obj.$api.msg('请输入手机号');
  86. return;
  87. }
  88. if (obj.addressDetail == '') {
  89. obj.$api.msg('请选择地址');
  90. return;
  91. }
  92. if (obj.detailed_address == '') {
  93. obj.$api.msg('请输入详细地址');
  94. return;
  95. }
  96. uni.showLoading({
  97. title: '提交中...',
  98. mask: true
  99. });
  100. editStore({
  101. shop_name: obj.storeName,
  102. shop_introduce: obj.storeinfo,
  103. name: obj.name,
  104. phone: obj.phone,
  105. province: obj.address.province,
  106. city: obj.address.city,
  107. district: obj.address.district,
  108. detail: obj.detailed_address,
  109. type: 2
  110. })
  111. .then(res => {
  112. uni.hideLoading();
  113. uni.showToast({
  114. title: '提交成功',
  115. duration: 2000
  116. });
  117. setTimeout(function() {
  118. uni.navigateBack();
  119. }, 800);
  120. })
  121. .catch(err => {
  122. uni.hideLoading();
  123. console.log(err);
  124. });
  125. },
  126. add() {
  127. let obj = this;
  128. if (obj.storeName == '') {
  129. obj.$api.msg('请输入店铺姓名');
  130. return;
  131. }
  132. if (obj.storeinfo == '') {
  133. obj.$api.msg('请输入店铺简介');
  134. return;
  135. }
  136. if (obj.name == '') {
  137. obj.$api.msg('请输入姓名');
  138. return;
  139. }
  140. if (obj.phone == '') {
  141. obj.$api.msg('请输入手机号');
  142. return;
  143. }
  144. if (obj.addressDetail == '') {
  145. obj.$api.msg('请选择地址');
  146. return;
  147. }
  148. if (obj.detailed_address == '') {
  149. obj.$api.msg('请输入详细地址');
  150. return;
  151. }
  152. uni.showLoading({
  153. title: '提交中...',
  154. mask: true
  155. });
  156. editStore({
  157. shop_name: obj.storeName,
  158. shop_introduce: obj.storeinfo,
  159. name: obj.name,
  160. phone: obj.phone,
  161. province: obj.address.province,
  162. city: obj.address.city,
  163. district: obj.address.district,
  164. detail: obj.detailed_address,
  165. type: 2
  166. })
  167. .then(res => {
  168. uni.hideLoading();
  169. uni.showToast({
  170. title: '提交成功',
  171. duration: 2000
  172. });
  173. setTimeout(function() {
  174. uni.navigateBack();
  175. }, 800);
  176. })
  177. .catch(err => {
  178. uni.hideLoading();
  179. console.log(err);
  180. });
  181. }
  182. }
  183. };
  184. </script>
  185. <style lang="scss" scoped>
  186. page {
  187. height: 100%;
  188. background-color: #f8f6f6;
  189. }
  190. .box {
  191. margin-top: 20rpx;
  192. }
  193. .item {
  194. background-color: #fff !important;
  195. min-height: 100rpx;
  196. display: flex;
  197. width: 690rpx;
  198. margin: 0 auto;
  199. .line {
  200. display: inline-block;
  201. line-height: 100rpx;
  202. }
  203. .item-tit {
  204. height: 100rpx;
  205. line-height: 100rpx;
  206. padding-left: 30rpx;
  207. width: 200rpx;
  208. font-size: 30rpx;
  209. font-family: PingFang SC;
  210. font-weight: 500;
  211. color: #666666;
  212. flex-shrink: 0;
  213. }
  214. input {
  215. width: 550rpx;
  216. height: 100rpx;
  217. line-height: 100rpx;
  218. font-size: 30rpx;
  219. font-family: PingFang SC;
  220. font-weight: 500;
  221. color: #333333;
  222. }
  223. .input {
  224. width: 550rpx;
  225. height: 100rpx;
  226. line-height: 100rpx;
  227. font-size: 30rpx;
  228. font-family: PingFang SC;
  229. font-weight: 500;
  230. color: #333333;
  231. }
  232. .up-wrapper {
  233. height: 352rpx;
  234. width: 550rpx;
  235. position: relative;
  236. image {
  237. position: absolute;
  238. height: 160rpx;
  239. width: 160rpx;
  240. top: 0;
  241. bottom: 0;
  242. left: 94rpx;
  243. margin: auto;
  244. }
  245. }
  246. }
  247. .sub {
  248. width: 100%;
  249. height: 88rpx;
  250. background: #ff4c4c;
  251. line-height: 88rpx;
  252. text-align: center;
  253. font-size: 36rpx;
  254. font-family: PingFang SC;
  255. font-weight: 500;
  256. color: #ffffff;
  257. position: fixed;
  258. bottom: 0;
  259. left: 0;
  260. right: 0;
  261. }
  262. .picker {
  263. display: inline-block;
  264. padding-right: 40rpx;
  265. height: 100rpx;
  266. line-height: 100rpx;
  267. }
  268. .prcker-t {
  269. padding-left: 40rpx;
  270. }
  271. </style>