add.php 13 KB

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