add_point.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. {include file="public/head"}
  5. <link href="/system/frame/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
  6. <link href="/system/frame/css/style.min.css?v=3.0.0" rel="stylesheet">
  7. <title>{$title|default=''}</title>
  8. <style></style>
  9. </head>
  10. <body>
  11. <div class="wrapper wrapper-content">
  12. <div class="row">
  13. <div class="col-sm-12">
  14. <div class="ibox float-e-margins">
  15. <div class="ibox-title">
  16. <h5>自提点设置</h5>
  17. </div>
  18. <div id="store-attr" class="mp-form" v-cloak="">
  19. <i-Form :label-width="80" style="width: 100%">
  20. <template>
  21. <Form-Item>
  22. <Row>
  23. <i-Col span="13">
  24. <span>自提点名称:</span>
  25. <i-Input placeholder="自提点名称" v-model="form.name" style="width: 80%"
  26. type="text"></i-Input>
  27. </i-Col>
  28. </Row>
  29. </Form-Item>
  30. <Form-Item>
  31. <Row>
  32. <i-Col span="13">
  33. <span>自提点手机号:</span>
  34. <i-Input placeholder="自提点手机号" v-model="form.phone" style="width: 80%"
  35. type="text"></i-Input>
  36. </i-Col>
  37. </Row>
  38. </Form-Item>
  39. <Form-Item>
  40. <Row>
  41. <i-Col span="13">
  42. <span>自提点地址:</span>
  43. <Cascader :data="addresData" :value.sync="form.address"
  44. @on-change="handleChange"
  45. style="width: 80%;display: inline-block;"></Cascader>
  46. </i-Col>
  47. </Row>
  48. </Form-Item>
  49. <Form-Item>
  50. <Row>
  51. <i-Col span="13">
  52. <span>详细地址:</span>
  53. <i-Input placeholder="详细地址" v-model="form.detailed_address" style="width: 80%"
  54. type="text"></i-Input>
  55. </i-Col>
  56. </Row>
  57. </Form-Item>
  58. <Form-Item>
  59. <Row>
  60. <i-Col span="13">
  61. <span>营业时间:</span>
  62. <Time-picker type="timerange" @on-change="changeDayTime" placement="bottom-end"
  63. :value="form.day_time" placeholder="选择时间"></Time-picker>
  64. </i-Col>
  65. </Row>
  66. </Form-Item>
  67. <Form-Item>
  68. <Row>
  69. <i-Col span="13">
  70. <span style="float: left">经纬度:</span>
  71. <Tooltip content="请点击查找位置进行选择位置">
  72. <i-Input placeholder="经纬度" v-model="form.latlng" :readonly="true"
  73. style="width: 80%">
  74. <span slot="append"
  75. @click="openWindows('查找位置','{:Url('select_address')}',{w:400,h:700})"
  76. style="cursor:pointer">查找位置</span>
  77. </i-Input>
  78. </Tooltip>
  79. </i-Col>
  80. </Row>
  81. </Form-Item>
  82. </template>
  83. <Form-Item>
  84. <Row>
  85. <i-Col span="8" offset="6">
  86. <i-Button type="primary" @click="submit">提交</i-Button>
  87. </i-Col>
  88. </Row>
  89. </Form-Item>
  90. </i-Form>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <script src="{__PLUG_PATH}city.js"></script>
  97. <script>
  98. var storeData = {:json_encode($store)};
  99. var store_id = {$store_id};
  100. mpFrame.start(function (Vue) {
  101. $.each(city, function (key, item) {
  102. city[key].value = item.label;
  103. if (item.children && item.children.length) {
  104. $.each(item.children, function (i, v) {
  105. city[key].children[i].value = v.label;
  106. if (v.children && v.children.length) {
  107. $.each(v.children, function (k, val) {
  108. city[key].children[i].children[k].value = val.label;
  109. });
  110. }
  111. });
  112. }
  113. });
  114. new Vue({
  115. data: function () {
  116. return {
  117. id: storeData.id || 0,
  118. addresData: city,
  119. form: {
  120. name: storeData.name || '',
  121. phone: storeData.phone || '',
  122. address: storeData.address || [],
  123. detailed_address: storeData.detailed_address || '',
  124. latlng: storeData.latlng || '',
  125. valid_time: storeData.valid_time || [],
  126. day_time: storeData.day_time || [],
  127. store_id: store_id,
  128. },
  129. visible: false,
  130. }
  131. },
  132. methods: {
  133. changeDayTime: function (date) {
  134. this.$set(this.form, 'day_time', date);
  135. },
  136. changeValidTime: function (date) {
  137. this.$set(this.form, 'valid_time', date);
  138. },
  139. createFrame: function (title, src, opt) {
  140. opt === undefined && (opt = {});
  141. var h = parent.document.body.clientHeight - 100;
  142. return layer.open({
  143. type: 2,
  144. title: title,
  145. area: [(opt.w || 700) + 'px', (opt.h || h) + 'px'],
  146. fixed: false, //不固定
  147. maxmin: true,
  148. moveOut: false,//true 可以拖出窗外 false 只能在窗内拖
  149. anim: 5,//出场动画 isOutAnim bool 关闭动画
  150. offset: 'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  151. shade: 0,//遮罩
  152. resize: true,//是否允许拉伸
  153. content: src,//内容
  154. move: '.layui-layer-title'
  155. });
  156. },
  157. handleChange: function (value, selectedData) {
  158. var that = this;
  159. that.form.address = [];
  160. $.each(selectedData, function (key, item) {
  161. that.form.address.push(item.label);
  162. });
  163. that.$set(that.form, 'address', that.form.address);
  164. },
  165. openWindows: function (title, url, opt) {
  166. return this.createFrame(title, url, opt);
  167. },
  168. changeIMG: function (name, url) {
  169. this.form[name] = url;
  170. },
  171. isPhone: function (test) {
  172. var reg = /^1[3456789]\d{9}$/;
  173. return reg.test(test);
  174. },
  175. submit: function () {
  176. var that = this;
  177. if (!that.form.name) return $eb.message('error', '请填写名称');
  178. if (!that.form.phone) return $eb.message('error', '请输入手机号码');
  179. if (!that.isPhone(that.form.phone)) return $eb.message('error', '请输入正确的手机号码');
  180. if (!that.form.address) return $eb.message('error', '请选择地址');
  181. if (!that.form.detailed_address) return $eb.message('error', '请填写详细地址');
  182. if (!that.form.valid_time) return $eb.message('error', '请选择核销时效');
  183. if (!that.form.day_time) return $eb.message('error', '请选择营业时间');
  184. if (!that.form.latlng) return $eb.message('error', '请选择经纬度!');
  185. if (!that.form.store_id) return $eb.message('error', '请选择所属门店!');
  186. var index = layer.load(1, {
  187. shade: [0.5, '#fff']
  188. });
  189. $eb.axios.post('{:Url("save_point")}' + (that.id ? '?id=' + that.id : ''), that.form).then(function (res) {
  190. layer.close(index);
  191. layer.msg(res.data.msg);
  192. if (res.data.data.id) that.id = res.data.data.id;
  193. }).catch(function (err) {
  194. console.log(err);
  195. layer.close(index);
  196. })
  197. },
  198. selectAdderss: function (data) {
  199. //lat 纬度 lng 经度
  200. this.form.latlng = data.latlng.lat + ',' + data.latlng.lng;
  201. }
  202. },
  203. mounted: function () {
  204. window.changeIMG = this.changeIMG;
  205. window.selectAdderss = this.selectAdderss;
  206. }
  207. }).$mount(document.getElementById('store-attr'))
  208. })
  209. </script>