addressAdd.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="app-delivery-module">
  3. <form @submit="formSubmit">
  4. <view class="module-com">
  5. <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="selectCityFn">
  6. <view class="tui-title">所在城市</view>
  7. <view class="tui-input" v-if="form.province || form.city" >{{ form.province + '-' + form.city }}</view> <view class="tui-placeholder" v-else>请选择</view>
  8. </tui-list-cell>
  9. <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="selRegionFn">
  10. <view class="tui-title">所在地址</view>
  11. <view class="tui-input" v-if="form.address">{{ form.address }}</view>
  12. <view class="tui-placeholder" v-else>请填写地址</view>
  13. </tui-list-cell>
  14. <tui-list-cell class="line-cell" :hover="false">
  15. <view class="tui-title">门牌号</view>
  16. <input v-model="form.floor" placeholder-class="phcolor" placeholder-style="color:#ccc" class="tui-input" name="floor" placeholder="楼号门牌号(选填)" />
  17. </tui-list-cell>
  18. <tui-list-cell class="line-cell" :hover="false">
  19. <div class="tui-title">默认地址</div>
  20. <view><switch style="transform:scale(0.7,0.7)" :checked="form.default == 0 ? false : true" @change="defaultChangeFn" /></view>
  21. </tui-list-cell>
  22. <tui-list-cell class="line-cell" :hover="false">
  23. <view class="tui-title">备注</view>
  24. <input v-model="form.remark" placeholder-class="phcolor" class="tui-input" placeholder-style="color:#ccc" name="remark" placeholder="选填" />
  25. </tui-list-cell>
  26. <div style="text-align:center;margin-top:10upx;">
  27. <button class="admin-button-com default big" style="width:230upx;margin-right:60upx;">取消</button>
  28. <button class="admin-button-com blue big" style="width:230upx;" formType="submit">确认</button>
  29. </div>
  30. </view>
  31. </form>
  32. <!-- 省市联动 -->
  33. <simple-address ref="simpleAddress" :region="regionTree" :pickerValueDefault="cityPickerValueDefault" @onConfirm="getCityConfirm" ></simple-address>
  34. <!-- 选择详细地址 -->
  35. <app-area-sel :show.sync="showRegion" :city="form.city" @change="changeAreaFn" />
  36. </view>
  37. </template>
  38. <script>
  39. import { mapGetters } from "vuex";
  40. import TuiListCell from "@/components/plugin/list-cell";
  41. import AppDatePicker from "@/components/app-date-picker";
  42. import SimpleAddress from "@/components/plugin/simple-address";
  43. import AppAreaSel from "@/components/app-area-sel";
  44. import AppBindInfo from "@/components/app-bind-info";
  45. import {getShop} from "@/api/common"
  46. import {getRegion} from "@/api/shop"
  47. import {addAddress} from "@/api/address"
  48. export default {
  49. name: "app-delivery-module",
  50. components: {
  51. AppAreaSel,
  52. TuiListCell,
  53. AppDatePicker,
  54. SimpleAddress,
  55. AppBindInfo
  56. },
  57. props: {
  58. info: {
  59. type: Object,
  60. default: {}
  61. },
  62. },
  63. data() {
  64. return {
  65. fillMobile:0,
  66. region: [],
  67. showRegion: false,
  68. form: {
  69. province: "",
  70. city: "",
  71. address: "",
  72. showAddress:"",
  73. floor: "",
  74. fullAddress: "",
  75. remark: "",
  76. lat:'',
  77. long:'',
  78. default:0
  79. },
  80. region: {latitude: 0,longitude: 0},
  81. regionTree:[],
  82. cityPickerValueDefault: [0, 0],
  83. timeOptions: [
  84. ['00', '01', '02','03','04','05','06','07','08','09','10','11','12','13', '14','15','16','17','18','19','20','21','22','23'],
  85. ['00', '05', '10','15','20','25','30','35','40','45','50','55']
  86. ],
  87. };
  88. },
  89. mounted() {
  90. let that = this
  91. getRegion().then(res=>{
  92. if(res.code == 1){
  93. that.regionTree = res.data.region
  94. getShop().then(res=>{
  95. if(res.code == 1){
  96. if(res.data.info){
  97. that.form.province = res.data.info.province
  98. that.form.city = res.data.info.city
  99. }
  100. }
  101. })
  102. }
  103. })
  104. },
  105. methods: {
  106. defaultChangeFn(e) {
  107. this.form.default = e.detail.value ? 1 : 0;
  108. },
  109. formSubmit () {
  110. let that = this
  111. if (this.$util.isEmpty(this.form.address)){
  112. this.$msg('请填写所在地址')
  113. return false
  114. }
  115. if (this.$util.isEmpty(this.form.lat) || this.$util.isEmpty(this.form.long)){
  116. this.$msg('请填写所在地址')
  117. return false
  118. }
  119. addAddress(this.form).then(res=>{
  120. if(res.code == 1){
  121. that.$msg(res.msg)
  122. setTimeout(function(){
  123. uni.navigateBack()
  124. },1500)
  125. }
  126. })
  127. },
  128. selRegionFn() {
  129. if (!this.form.city) {
  130. this.$msg("请选择城市");
  131. return false;
  132. }
  133. this.showRegion = true;
  134. },
  135. changeAreaFn(e) {
  136. this.form.address = e.title;
  137. this.form.showAddress = e.address;
  138. this.form.lat = e.location.lat;
  139. this.form.long = e.location.lng;
  140. },
  141. selectCityFn() {
  142. this.$refs.simpleAddress.open();
  143. },
  144. getCityConfirm(e) {
  145. this.form.province = e.provinceName;
  146. this.form.city = e.cityName;
  147. }
  148. }
  149. };
  150. </script>
  151. <style lang="scss" scoped>
  152. .app-delivery-module {
  153. .module-com {
  154. margin-bottom: 20upx;
  155. background-color: #fff;
  156. .module-tit {
  157. padding: 20upx 18upx;
  158. font-size: 28upx;
  159. font-weight: 600;
  160. border-bottom: 1px solid $borderColor;
  161. }
  162. .module-det {
  163. padding: 0 30upx;
  164. }
  165. }
  166. // 公共
  167. .line-cell {
  168. .tui-title {
  169. width: 210upx;
  170. color: $fontColor2;
  171. }
  172. .tui-input {
  173. width: calc(100% - 210upx);
  174. font-size: 28upx;
  175. }
  176. .tui-placeholder {
  177. color: #ccc;
  178. }
  179. .phcolor {
  180. color: #ccc;
  181. }
  182. }
  183. .delivery-time {
  184. @include disFlex(center, center);
  185. .button-com {
  186. padding-top: 14upx;
  187. padding-bottom: 10upx;
  188. margin-right:10upx;
  189. }
  190. }
  191. .gift-wrap {
  192. .gift-content {
  193. width: 100%;
  194. }
  195. .need-gift {
  196. margin-left: 14upx;
  197. color: $fontColor2;
  198. }
  199. .gitf-textarea {
  200. margin-top: 40upx;
  201. }
  202. }
  203. .none-name-delivery {
  204. margin-bottom: 20upx;
  205. background-color: #fff;
  206. .none-name-text {
  207. margin-left: 10upx;
  208. color: $fontColor2;
  209. }
  210. }
  211. }
  212. </style>