setting.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="content bg-drak ft-main">
  3. <use-tabbar :tabbar="false"></use-tabbar>
  4. <view class="gap"></view>
  5. <view class="row dflex padding-lr">
  6. <text class="tit">店铺名称</text>
  7. <input class="input" placeholder="请输入店铺名称" maxlength="140" v-model="fetch.name"/>
  8. </view>
  9. <view class="row dflex padding-lr">
  10. <text class="tit">联系人</text>
  11. <input class="input" placeholder="请输入联系人姓名" maxlength="340" v-model="fetch.truename"/>
  12. </view>
  13. <view class="row dflex padding-lr">
  14. <text class="tit">宣传语</text>
  15. <input class="input" placeholder="请输入宣传语" maxlength="340" v-model="fetch.info"/>
  16. </view>
  17. <view class="row dflex padding-left" v-if="fetch.area">
  18. <text class="tit">所在地区</text>
  19. <view class="dflex-b flex1">
  20. <view class="flex1 input_t" @click="openAddress">{{ fetch.area_string }}</view>
  21. <sx-address-picker v-model="address" :selected="fetch.area" @confirm="addressConfirm"/>
  22. </view>
  23. </view>
  24. <view class="use-area margin-lr-sm" v-if="fetch.area">
  25. <view class="tit">详细地址</view>
  26. <textarea class="bg-drak w-full border-radius-sm margin-top-sm padding" placeholder="请输入详细地址" maxlength="120" style="min-height: 70px; height: auto;" v-model="fetch.address"/>
  27. </view>
  28. <view class="padding w-full margin-top-big" @click="save">
  29. <view class="dflex-b border-radius-big">
  30. <view class="tac padding-tb-sm flex1 bg-base">提交</view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. address:false,
  40. fetch: {
  41. id:-1,
  42. province_id:0,
  43. city_id:0,
  44. county_id:0,
  45. town_id:0,
  46. address:'',
  47. name:'',
  48. truename: '',
  49. info:'',
  50. sales_type:0,
  51. sales_id:0,
  52. area:['CN', '11', '1101', '110107', '110107005'],
  53. area_string: '请选择地址',
  54. }
  55. };
  56. },
  57. onLoad(options) {
  58. this.fetch.sales_type = options.type;
  59. this.fetch.sales_id = options.id;
  60. if (!this.fetch.sales_type || !this.fetch.sales_id) {
  61. return Dever.goUser()
  62. }
  63. },
  64. onShow() {
  65. this.loadData();
  66. },
  67. methods: {
  68. loadData() {
  69. this.DeverApi.get(this, 'sales.getInfo', {sales_type:this.fetch.sales_type, sales_id: this.fetch.sales_id});
  70. },
  71. save() {
  72. if (!this.fetch.name) {
  73. return this.Dever.alert('请输入店铺名称');
  74. }
  75. if (!this.fetch.info) {
  76. return this.Dever.alert('请输入宣传语');
  77. }
  78. if (!this.fetch.truename) {
  79. return this.Dever.alert('请输入联系人姓名');
  80. }
  81. if (!this.fetch.province_id) {
  82. return this.Dever.alert('请选择省份');
  83. }
  84. if (!this.fetch.city_id) {
  85. return this.Dever.alert('请选择城市');
  86. }
  87. if (!this.fetch.county_id) {
  88. return this.Dever.alert('请选择区县');
  89. }
  90. if (!this.fetch.town_id) {
  91. return this.Dever.alert('请选择街道');
  92. }
  93. if (!this.fetch.address) {
  94. return this.Dever.alert('请输入详细地址');
  95. }
  96. this.DeverApi.post('sales.update', this.fetch, res => {
  97. this.Dever.success('提交成功', () => {
  98. uni.navigateBack()
  99. });
  100. });
  101. },
  102. openAddress() {
  103. this.address = true
  104. },
  105. // 选择地址
  106. addressConfirm(res) {
  107. var name = [];
  108. res.forEach((item, index) => {
  109. if (index > 0) {
  110. if (name != '市辖区') {
  111. name.push(item.name)
  112. }
  113. if (index == 1) {
  114. this.fetch.province_id = item.code;
  115. } else if (index == 2) {
  116. this.fetch.city_id = item.code;
  117. } else if (index == 3) {
  118. this.fetch.county_id = item.code;
  119. } else if (index == 4) {
  120. this.fetch.town_id = item.code;
  121. }
  122. }
  123. });
  124. this.fetch.area_string = name.join('-')
  125. },
  126. }
  127. };
  128. </script>
  129. <style lang="scss">
  130. .row {
  131. background: #fff;
  132. position: relative;
  133. height: 104rpx;
  134. margin: 18rpx;
  135. border-radius: 18rpx;
  136. .input {
  137. flex: 1;
  138. font-size: 28rpx;
  139. padding-left: 0;
  140. }
  141. .tit {
  142. flex-shrink: 0;
  143. width: 144rpx;
  144. }
  145. }
  146. .use-area {
  147. border-radius: 18rpx;
  148. background: #fff;
  149. padding: 28rpx;
  150. margin-top: 18rpx;
  151. }
  152. </style>