add.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. <Alert type="warning">除门店简介外其他选项都是必填项</Alert>
  22. <Form-Item>
  23. <Row>
  24. <i-Col span="13">
  25. <span>门店名称:</span>
  26. <i-Input placeholder="门店名称" v-model="form.name" style="width: 80%"
  27. type="text"></i-Input>
  28. </i-Col>
  29. </Row>
  30. </Form-Item>
  31. <Form-Item>
  32. <Row>
  33. <i-Col span="13">
  34. <span>门店简介:</span>
  35. <i-Input placeholder="门店简介" v-model="form.introduction" style="width: 80%"
  36. type="text"></i-Input>
  37. </i-Col>
  38. </Row>
  39. </Form-Item>
  40. <Form-Item>
  41. <Row>
  42. <i-Col span="13">
  43. <span>门店店长:</span>
  44. <i-Input placeholder="门店店长" v-model="form.leader" style="width: 80%"
  45. type="text"></i-Input>
  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.phone" 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. <Cascader :data="addresData" :value.sync="form.address"
  63. @on-change="handleChange"
  64. style="width: 80%;display: inline-block;"></Cascader>
  65. </i-Col>
  66. </Row>
  67. </Form-Item>
  68. <Form-Item>
  69. <Row>
  70. <i-Col span="13">
  71. <span>详细地址:</span>
  72. <i-Input placeholder="详细地址" v-model="form.detailed_address" style="width: 80%"
  73. type="text"></i-Input>
  74. </i-Col>
  75. </Row>
  76. </Form-Item>
  77. <!-- <Form-Item>-->
  78. <!-- <Row>-->
  79. <!-- <i-Col span="13">-->
  80. <!-- <span>核销时效:</span>-->
  81. <!-- <Date-picker type="daterange" @on-change="changeValidTime" placeholder="选择日期" :value="form.valid_time"></Date-picker>-->
  82. <!-- </i-Col>-->
  83. <!-- </Row>-->
  84. <!-- </Form-Item>-->
  85. <Form-Item>
  86. <Row>
  87. <i-Col span="13">
  88. <span>营业时间:</span>
  89. <Time-picker type="timerange" @on-change="changeDayTime" placement="bottom-end"
  90. :value="form.day_time" placeholder="选择时间"></Time-picker>
  91. </i-Col>
  92. </Row>
  93. </Form-Item>
  94. <Form-Item>
  95. <Row>
  96. <i-Col span="13">
  97. <span>门店logo:</span>
  98. <div class="demo-upload-list" v-if="form.image">
  99. <template>
  100. <img :src="form.image">
  101. <div class="demo-upload-list-cover">
  102. <Icon type="ios-eye-outline" @click="visible = true "></Icon>
  103. <Icon type="ios-trash-outline" @click="form.image=''"></Icon>
  104. </div>
  105. </template>
  106. </div>
  107. <div class="ivu-upload" style="display: inline-block; width: 58px;"
  108. @click="openWindows('选择图片','{:Url('widget.images/index',['fodder'=>'image'])}',{w:900,h:550})"
  109. v-if="!form.image">
  110. <div class="ivu-upload ivu-upload-drag">
  111. <div style="width: 58px; height: 58px; line-height: 58px;">
  112. <i class="ivu-icon ivu-icon-camera" style="font-size: 20px;"></i>
  113. </div>
  114. </div>
  115. </div>
  116. <Modal title="查看图片" :visible.sync="visible">
  117. <img :src="form.image" v-if="visible" style="width: 100%">
  118. </Modal>
  119. </i-Col>
  120. </Row>
  121. </Form-Item>
  122. <Form-Item>
  123. <Row>
  124. <i-Col span="13">
  125. <span style="float: left">经纬度:</span>
  126. <Tooltip content="请点击查找位置进行选择位置">
  127. <i-Input placeholder="经纬度" v-model="form.latlng" :readonly="true"
  128. style="width: 80%">
  129. <span slot="append"
  130. @click="openWindows('查找位置','{:Url('select_address')}',{w:400,h:700})"
  131. style="cursor:pointer">查找位置</span>
  132. </i-Input>
  133. </Tooltip>
  134. </i-Col>
  135. </Row>
  136. </Form-Item>
  137. <Form-Item>
  138. <Row>
  139. <i-Col span="13">
  140. <span>充值分红:</span>
  141. <i-Input placeholder="充值分红" v-model="form.recharge_award_ratio"
  142. style="width: 80%" type="text"></i-Input>
  143. </i-Col>
  144. </Row>
  145. </Form-Item>
  146. </template>
  147. <Form-Item>
  148. <Row>
  149. <i-Col span="8" offset="6">
  150. <i-Button type="primary" @click="submit">提交</i-Button>
  151. </i-Col>
  152. </Row>
  153. </Form-Item>
  154. </i-Form>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. <script src="{__PLUG_PATH}city.js"></script>
  161. <script>
  162. var storeData = {
  163. :
  164. json_encode($store)
  165. }
  166. ;
  167. mpFrame.start(function (Vue) {
  168. $.each(city, function (key, item) {
  169. city[key].value = item.label;
  170. if (item.children && item.children.length) {
  171. $.each(item.children, function (i, v) {
  172. city[key].children[i].value = v.label;
  173. if (v.children && v.children.length) {
  174. $.each(v.children, function (k, val) {
  175. city[key].children[i].children[k].value = val.label;
  176. });
  177. }
  178. });
  179. }
  180. });
  181. new Vue({
  182. data: function () {
  183. return {
  184. id: storeData.id || 0,
  185. addresData: city,
  186. form: {
  187. name: storeData.name || '',
  188. introduction: storeData.introduction || '',
  189. leader: storeData.leader || '',
  190. phone: storeData.phone || '',
  191. address: storeData.address || [],
  192. image: storeData.image || '',
  193. detailed_address: storeData.detailed_address || '',
  194. latlng: storeData.latlng || '',
  195. valid_time: storeData.valid_time || [],
  196. day_time: storeData.day_time || [],
  197. recharge_award_ratio: storeData.recharge_award_ratio || 0,
  198. },
  199. visible: false,
  200. }
  201. },
  202. methods: {
  203. changeDayTime: function (date) {
  204. this.$set(this.form, 'day_time', date);
  205. },
  206. changeValidTime: function (date) {
  207. this.$set(this.form, 'valid_time', date);
  208. },
  209. createFrame: function (title, src, opt) {
  210. opt === undefined && (opt = {});
  211. var h = parent.document.body.clientHeight - 100;
  212. return layer.open({
  213. type: 2,
  214. title: title,
  215. area: [(opt.w || 700) + 'px', (opt.h || h) + 'px'],
  216. fixed: false, //不固定
  217. maxmin: true,
  218. moveOut: false,//true 可以拖出窗外 false 只能在窗内拖
  219. anim: 5,//出场动画 isOutAnim bool 关闭动画
  220. offset: 'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  221. shade: 0,//遮罩
  222. resize: true,//是否允许拉伸
  223. content: src,//内容
  224. move: '.layui-layer-title'
  225. });
  226. },
  227. handleChange: function (value, selectedData) {
  228. var that = this;
  229. that.form.address = [];
  230. $.each(selectedData, function (key, item) {
  231. that.form.address.push(item.label);
  232. });
  233. that.$set(that.form, 'address', that.form.address);
  234. },
  235. openWindows: function (title, url, opt) {
  236. return this.createFrame(title, url, opt);
  237. },
  238. changeIMG: function (name, url) {
  239. this.form[name] = url;
  240. },
  241. isPhone: function (test) {
  242. var reg = /^1[3456789]\d{9}$/;
  243. return reg.test(test);
  244. },
  245. submit: function () {
  246. var that = this;
  247. if (!that.form.name) return $eb.message('error', '请填写门店行名称');
  248. if (!that.form.phone) return $eb.message('error', '请输入手机号码');
  249. if (!that.isPhone(that.form.phone)) return $eb.message('error', '请输入正确的手机号码');
  250. if (!that.form.address) return $eb.message('error', '请选择门店地址');
  251. if (!that.form.detailed_address) return $eb.message('error', '请填写门店详细地址');
  252. if (!that.form.image) return $eb.message('error', '请选择门店logo');
  253. if (!that.form.valid_time) return $eb.message('error', '请选择核销时效');
  254. if (!that.form.day_time) return $eb.message('error', '请选择门店营业时间');
  255. if (!that.form.latlng) return $eb.message('error', '请选择门店经纬度!');
  256. var index = layer.load(1, {
  257. shade: [0.5, '#fff']
  258. });
  259. $eb.axios.post('{:Url("save")}' + (that.id ? '?id=' + that.id : ''), that.form).then(function (res) {
  260. layer.close(index);
  261. layer.msg(res.data.msg);
  262. if (res.data.data.id) that.id = res.data.data.id;
  263. }).catch(function (err) {
  264. console.log(err);
  265. layer.close(index);
  266. })
  267. },
  268. selectAdderss: function (data) {
  269. //lat 纬度 lng 经度
  270. this.form.latlng = data.latlng.lat + ',' + data.latlng.lng;
  271. }
  272. },
  273. mounted: function () {
  274. window.changeIMG = this.changeIMG;
  275. window.selectAdderss = this.selectAdderss;
  276. }
  277. }).$mount(document.getElementById('store-attr'))
  278. })
  279. </script>