apply.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <view class="cn">
  4. <u-steps :list="numList" mode="number" :current="num" active-color="#c74547"></u-steps>
  5. <u-subsection :list="subsection" :current="current" @change="section" button-color="#c74547" active-color="#ffffff"></u-subsection>
  6. <view class="info">
  7. <view class="form_group hr">
  8. <view class="lable">商铺名称</view>
  9. <input type="text" placeholder="请输入商铺名称" v-model="item.name" />
  10. </view>
  11. <view class="form_group hr">
  12. <view class="lable">商铺地址</view>
  13. <input type="text" placeholder="请输入商铺地址" v-model="item.addres" />
  14. </view>
  15. <view class="form_group hr">
  16. <view class="lable">老板名称</view>
  17. <input type="text" placeholder="请输入老板名称" v-model="item.bossName" />
  18. </view>
  19. <view class="form_group hr">
  20. <view class="lable">老板电话</view>
  21. <input type="number" placeholder="请输入老板电话" v-model="item.bossPhone" />
  22. </view>
  23. <view class="form_group hr">
  24. <view class="lable">地图坐标</view>
  25. <input type="number" placeholder="请在地图上选择坐标" @click="wz()" v-model="zb" :disabled="true" />
  26. </view>
  27. <view class="form_group hr">
  28. <view class="lable">商铺简介</view>
  29. <textarea placeholder="请输入商铺简介" v-model="item.briefContent" />
  30. </view>
  31. </view>
  32. <button class="btn" @click="up()" v-if="!item.auditFlag">申请开通</button>
  33. <button class="btn" @click="up()" v-if="item.auditFlag == 0">更新资料</button>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. subsection: [{ name: '商铺', value: 1 }, { name: '酒店', value: 2 }],
  42. numList: [{ name: '资料填写' }, { name: '资料审核' }, { name: '审核通过' }],
  43. num: 0,
  44. current: 0,
  45. item: {},
  46. zb: ''
  47. };
  48. },
  49. onLoad(e) {
  50. if (e.item) {
  51. this.item = JSON.parse(e.item);
  52. if(this.item.lat){
  53. this.zb = '纬度:' + this.item.lat + ' 经度:' + this.item.lng;
  54. }
  55. this.subsection.forEach((item,index)=>{
  56. if(item.value==this.item.shopType){
  57. this.current=index;
  58. }
  59. })
  60. this.item.shopType = this.subsection[this.current].value;
  61. if (this.item.auditFlag == 0) {
  62. this.num = 1;
  63. }
  64. if (this.item.auditFlag == 1) {
  65. this.num = 2;
  66. }
  67. }
  68. },
  69. methods: {
  70. section(current) {
  71. this.current = current;
  72. },
  73. wz() {
  74. uni.getLocation({
  75. type: 'gcj02', //返回可以用于uni.openLocation的经纬度
  76. success: res => {
  77. uni.chooseLocation({
  78. success: r => {
  79. this.zb = '纬度:' + r.latitude + ' 经度:' + r.longitude;
  80. this.item.lat = r.latitude;
  81. this.item.lng = r.longitude;
  82. }
  83. });
  84. },
  85. fail: res => {
  86. console.log('zx:' + JSON.stringify(res));
  87. }
  88. });
  89. },
  90. up() {
  91. this.item.shopType = this.subsection[this.current].value;
  92. this.item.memberId = this.$getUser().memberId;
  93. let rule = [
  94. { name: 'name', checkType: 'notnull', errorMsg: '请输入商铺名称' },
  95. { name: 'addres', checkType: 'notnull', errorMsg: '请输入商铺地址' },
  96. { name: 'bossName', checkType: 'notnull', errorMsg: '请输入老板名称' },
  97. { name: 'bossPhone', checkType: 'notnull', errorMsg: '请输入老板电话' },
  98. { name: 'lat', checkType: 'notnull', errorMsg: '请在地图上选择坐标' }
  99. ];
  100. if (!this.$verify.check(this.item, rule)) {
  101. uni.showModal({ content: this.$verify.error, showCancel: false });
  102. return;
  103. }
  104. this.$http.request({
  105. method: 'POST',
  106. url: this.item.shopId ? this.$http.urls.updateShop : this.$http.urls.shopApply,
  107. data: this.item,
  108. success: res => {
  109. uni.showToast({ title: '提交成功' });
  110. setTimeout(() => {
  111. uni.$emit('shop');
  112. uni.navigateBack();
  113. }, 700);
  114. }
  115. });
  116. }
  117. }
  118. };
  119. </script>
  120. <style lang="scss">
  121. .steps {
  122. text-align: center;
  123. margin-top: 20px;
  124. }
  125. .u-subsection {
  126. margin-top: 20px;
  127. }
  128. .cn {
  129. padding: 15px;
  130. .info {
  131. background-color: white;
  132. border-radius: 5px;
  133. margin-top: 10px;
  134. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  135. }
  136. .btn {
  137. margin-top: 25px;
  138. }
  139. }
  140. </style>