info.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', trans('退货地址模板详情'))
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
  5. <div class="all">
  6. <div id="app" v-cloak>
  7. <div class="vue-crumbs">
  8. <a @click="goParent">退货地址列表</a> > 退货地址模板详情
  9. </div>
  10. <div class="vue-main">
  11. <div class="vue-main-title">
  12. <div class="vue-main-title-left"></div>
  13. <div class="vue-main-title-content">退货地址模板详情</div>
  14. </div>
  15. <div class="vue-main-form">
  16. <el-form ref="form" :model="form" :rules="rules" label-width="15%">
  17. <el-form-item label="退货地址名称" prop="address_name">
  18. <el-input v-model="form.address_name" style="width:70%;"></el-input>
  19. </el-form-item>
  20. <el-form-item label="联系人" prop="alias">
  21. <el-input v-model="form.contact" style="width:70%;"></el-input>
  22. </el-form-item>
  23. <el-form-item label="联系人手机" prop="alias">
  24. <el-input v-model="form.mobile" style="width:70%;"></el-input>
  25. </el-form-item>
  26. <el-form-item label="联系人电话" prop="alias">
  27. <el-input v-model="form.telephone" style="width:70%;"></el-input>
  28. </el-form-item>
  29. <el-form-item label="注册地址" prop="" v-loading="areaLoading">
  30. <el-select v-model="p.province" placeholder="请选择省" clearable @change="changeProvince" :style="street==1?'width:17.5%':'width:23.3%'">
  31. <el-option v-for="item in province_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  32. </el-select>
  33. <el-select v-model="p.city" placeholder="请选择市" clearable @change="changeCity" :style="street==1?'width:17.5%':'width:23.3%'">
  34. <el-option v-for="item in city_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  35. </el-select>
  36. <el-select v-model="p.district" placeholder="请选择区" clearable @change="changeDistrict" :style="street==1?'width:17.5%':'width:23.3%'">
  37. <el-option v-for="item in district_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  38. </el-select>
  39. <el-select v-model="p.street" placeholder="请选择街道" clearable :style="street==1?'width:17.5%':'width:23.3%'">
  40. <el-option v-for="item in street_list" :key="item.id" :label="item.areaname" :value="item.id"></el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item label="详细地址" prop="alias">
  44. <el-input v-model="form.address" style="width:70%;"></el-input>
  45. </el-form-item>
  46. <el-form-item label="是否默认" prop="is_recommend">
  47. <el-switch v-model="form.is_default" :active-value="1" :inactive-value="0"></el-switch>
  48. </el-form-item>
  49. </el-form>
  50. </div>
  51. </div>
  52. <!-- 分页 -->
  53. <div class="vue-page">
  54. <div class="vue-center">
  55. <el-button type="primary" @click="submitForm('form')">保存设置</el-button>
  56. <el-button @click="goBack">返回</el-button>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <script>
  62. var app = new Vue({
  63. el:"#app",
  64. delimiters: ['[[', ']]'],
  65. name: 'test',
  66. data() {
  67. let id = {!! $id?:0 !!};
  68. console.log(id);
  69. return{
  70. id:id,
  71. form:{
  72. },
  73. centerDialogVisible:false,
  74. showVisible:false,
  75. loading: false,
  76. rules:{
  77. name:{ required: true, message: '请输入退货地址名称名称'}
  78. },
  79. p:{
  80. province:'',
  81. city:'',
  82. district:'',
  83. street:'',
  84. },
  85. province_list:[],
  86. city_list:[],
  87. district_list:[],
  88. street_list:[],
  89. areaLoading:false,
  90. street:1,
  91. submit_url:''
  92. }
  93. },
  94. created() {
  95. },
  96. mounted() {
  97. // this.getData();
  98. this.initProvince();
  99. if(this.id) {
  100. this.getData();
  101. this.submit_url = '{!! yzWebFullUrl('goods.return-address.edit') !!}';
  102. }
  103. else {
  104. this.submit_url = '{!! yzWebFullUrl('goods.return-address.add') !!}';
  105. }
  106. },
  107. methods: {
  108. getData() {
  109. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  110. this.$http.post('{!! yzWebFullUrl('goods.return-address.edit') !!}',{id:this.id}).then(function (response) {
  111. console.log(response.data,33333)
  112. if (response.data.result){
  113. this.form = {
  114. ...response.data.data,
  115. };
  116. console.log(this.form.province_id,this.form.city_id,this.form.district_id,888888)
  117. this.changeProvince(this.form.province_id);
  118. this.changeCity(this.form.city_id);
  119. this.changeDistrict(this.form.district_id)
  120. this.p.province = this.form.province_id;
  121. this.p.city = this.form.city_id;
  122. this.p.district = this.form.district_id;
  123. this.p.street = this.form.street_id;
  124. }
  125. else {
  126. this.$message({message: response.data.msg,type: 'error'});
  127. }
  128. loading.close();
  129. },function (response) {
  130. this.$message({message: response.data.msg,type: 'error'});
  131. loading.close();
  132. }
  133. );
  134. },
  135. initProvince(val) {
  136. console.log(val);
  137. this.areaLoading = true;
  138. this.$http.get("{!! yzWebUrl('area.list.init', ['area_ids'=>'']) !!}"+val).then(response => {
  139. this.province_list = response.data.data;
  140. this.areaLoading = false;
  141. }, response => {
  142. this.areaLoading = false;
  143. });
  144. },
  145. changeProvince(val) {
  146. this.city_list = [];
  147. this.district_list = [];
  148. this.street_list = [];
  149. this.p.city = "";
  150. this.p.district = "";
  151. this.p.street = "";
  152. this.areaLoading = true;
  153. let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
  154. this.$http.get(url).then(response => {
  155. if (response.data.data.length) {
  156. this.city_list = response.data.data;
  157. } else {
  158. this.city_list = null;
  159. }
  160. this.areaLoading = false;
  161. }, response => {
  162. this.areaLoading = false;
  163. });
  164. },
  165. // 市改变
  166. changeCity(val) {
  167. this.district_list = [];
  168. this.street_list = [];
  169. this.p.district = "";
  170. this.p.street = "";
  171. this.areaLoading = true;
  172. let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
  173. this.$http.get(url).then(response => {
  174. if (response.data.data.length) {
  175. this.district_list = response.data.data;
  176. } else {
  177. this.district_list = null;
  178. }
  179. this.areaLoading = false;
  180. }, response => {
  181. this.areaLoading = false;
  182. });
  183. },
  184. // 区改变
  185. changeDistrict(val) {
  186. console.log(val)
  187. this.street_list = [];
  188. this.p.street = "";
  189. this.areaLoading = true;
  190. let url = "<?php echo yzWebUrl('area.list', ['parent_id'=> '']); ?>" + val;
  191. this.$http.get(url).then(response => {
  192. if (response.data.data.length) {
  193. this.street_list = response.data.data;
  194. } else {
  195. this.street_list = null;
  196. }
  197. this.areaLoading = false;
  198. }, response => {
  199. this.areaLoading = false;
  200. });
  201. },
  202. submitForm(formName) {
  203. let that = this;
  204. let json = this.form;
  205. json.province_id = this.p.province;
  206. json.city_id = this.p.city;
  207. json.district_id = this.p.district;
  208. json.street_id = this.p.street;
  209. let json1 = {
  210. address:json
  211. }
  212. if(this.id) {
  213. json1.id = this.id
  214. }
  215. this.$refs[formName].validate((valid) => {
  216. if (valid) {
  217. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  218. this.$http.post(this.submit_url,json1).then(response => {
  219. if (response.data.result) {
  220. this.$message({type: 'success',message: '操作成功!'});
  221. this.goBack();
  222. } else {
  223. this.$message({message: response.data.msg,type: 'error'});
  224. }
  225. loading.close();
  226. },response => {
  227. loading.close();
  228. });
  229. }
  230. else {
  231. console.log('error submit!!');
  232. return false;
  233. }
  234. });
  235. },
  236. goBack() {
  237. history.go(-1)
  238. },
  239. goParent() {
  240. window.location.href = `{!! yzWebFullUrl('goods.return-address.index') !!}`;
  241. },
  242. },
  243. })
  244. </script>
  245. @endsection