add.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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>
  62. <Row>
  63. <i-Col span="13">
  64. <span>门店名称:</span>
  65. <i-Input placeholder="门店名称" v-model="form.name" style="width: 80%" type="text"></i-Input>
  66. </i-Col>
  67. </Row>
  68. </Form-Item>
  69. <Form-Item>
  70. <Row>
  71. <i-Col span="13">
  72. <span>门店简介:</span>
  73. <i-Input placeholder="门店简介" v-model="form.introduction" style="width: 80%" 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. <i-Input placeholder="门店手机号" v-model="form.phone" style="width: 80%" type="text"></i-Input>
  82. </i-Col>
  83. </Row>
  84. </Form-Item>
  85. <Form-Item>
  86. <Row>
  87. <i-Col span="13">
  88. <span>门店地址:</span>
  89. <Cascader :data="addresData" :value.sync="form.address" @on-change="handleChange" style="width: 80%;display: inline-block;"></Cascader>
  90. </i-Col>
  91. </Row>
  92. </Form-Item>
  93. <Form-Item>
  94. <Row>
  95. <i-Col span="13">
  96. <span>详细地址:</span>
  97. <i-Input placeholder="详细地址" v-model="form.detailed_address" style="width: 80%" type="text"></i-Input>
  98. </i-Col>
  99. </Row>
  100. </Form-Item>
  101. <Form-Item>
  102. <Row>
  103. <i-Col span="13">
  104. <span>门店自提:</span>
  105. <Radio-group v-model="form.is_pick" style="margin-left: 10px;">
  106. <Radio label="1">开启</Radio>
  107. <Radio label="0">关闭</Radio>
  108. </Radio-group>
  109. </i-Col>
  110. </Row>
  111. </Form-Item>
  112. <Form-Item>
  113. <Row>
  114. <i-Col span="13">
  115. <span>营业时间:</span>
  116. <Time-picker type="timerange" @on-change="changeDayTime" placement="bottom-end" :value="form.day_time" placeholder="选择时间"></Time-picker>
  117. </i-Col>
  118. </Row>
  119. </Form-Item>
  120. <Form-Item>
  121. <Row>
  122. <i-Col span="13">
  123. <span>门店logo:</span>
  124. <div class="demo-upload-list" v-if="form.image">
  125. <template>
  126. <img :src="form.image">
  127. <div class="demo-upload-list-cover">
  128. <Icon type="ios-eye-outline" @click="visible = true "></Icon>
  129. <Icon type="ios-trash-outline" @click="form.image=''"></Icon>
  130. </div>
  131. </template>
  132. </div>
  133. <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">
  134. <div class="ivu-upload ivu-upload-drag">
  135. <div style="width: 58px; height: 58px; line-height: 58px;">
  136. <i class="ivu-icon ivu-icon-camera" style="font-size: 20px;"></i>
  137. </div>
  138. </div>
  139. </div>
  140. <Modal title="查看图片" :visible.sync="visible">
  141. <img :src="form.image" v-if="visible" style="width: 100%">
  142. </Modal>
  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={:json_encode($store)};
  163. mpFrame.start(function(Vue) {
  164. $.each(city,function (key,item) {
  165. city[key].value = item.label;
  166. if(item.children && item.children.length){
  167. $.each(item.children,function (i,v) {
  168. city[key].children[i].value=v.label;
  169. if(v.children && v.children.length){
  170. $.each(v.children,function (k,val) {
  171. city[key].children[i].children[k].value=val.label;
  172. });
  173. }
  174. });
  175. }
  176. });
  177. new Vue({
  178. data:function() {
  179. return {
  180. id:storeData.id || 0,
  181. addresData:city,
  182. form:{
  183. name:storeData.name || '',
  184. introduction:storeData.introduction || '',
  185. phone:storeData.phone || '',
  186. address:storeData.address || [],
  187. image:storeData.image || '',
  188. detailed_address:storeData.detailed_address || '',
  189. latlng:storeData.latlng || '',
  190. valid_time:storeData.valid_time || [],
  191. day_time:storeData.day_time || [],
  192. // 确保 is_pick 是字符串类型,以匹配 Radio 的 label="1"
  193. is_pick: String(storeData.is_pick !== undefined ? storeData.is_pick : '1'),
  194. },
  195. visible:false,
  196. }
  197. },
  198. methods:{
  199. changeDayTime:function(date){
  200. this.$set(this.form,'day_time',date);
  201. },
  202. changeValidTime:function(date){
  203. this.$set(this.form,'valid_time',date);
  204. },
  205. createFrame:function(title,src,opt){
  206. opt === undefined && (opt = {});
  207. var h = parent.document.body.clientHeight - 100;
  208. return layer.open({
  209. type: 2,
  210. title:title,
  211. area: [(opt.w || 700)+'px', (opt.h || h)+'px'],
  212. fixed: false, //不固定
  213. maxmin: true,
  214. moveOut:false,//true 可以拖出窗外 false 只能在窗内拖
  215. anim:5,//出场动画 isOutAnim bool 关闭动画
  216. offset:'auto',//['100px','100px'],//'auto',//初始位置 ['100px','100px'] t[ 上 左]
  217. shade:0,//遮罩
  218. resize:true,//是否允许拉伸
  219. content: src,//内容
  220. move:'.layui-layer-title'
  221. });
  222. },
  223. handleChange:function(value,selectedData){
  224. var that = this;
  225. that.form.address = [];
  226. $.each(selectedData,function (key,item) {
  227. that.form.address.push(item.label);
  228. });
  229. that.$set(that.form,'address',that.form.address);
  230. },
  231. openWindows:function(title,url,opt){
  232. return this.createFrame(title,url,opt);
  233. },
  234. changeIMG:function(name,url){
  235. this.form[name]=url;
  236. },
  237. isPhone:function(test){
  238. var reg = /^1[3456789]\d{9}$/;
  239. return reg.test(test);
  240. },
  241. submit:function () {
  242. var that = this;
  243. if(!that.form.name) return $eb.message('error','请填写门店行名称');
  244. if(!that.form.phone) return $eb.message('error','请输入手机号码');
  245. if(!that.isPhone(that.form.phone)) return $eb.message('error','请输入正确的手机号码');
  246. if(!that.form.address) return $eb.message('error','请选择门店地址');
  247. if(!that.form.detailed_address) return $eb.message('error','请填写门店详细地址');
  248. if(!that.form.image) return $eb.message('error','请选择门店logo');
  249. if(!that.form.day_time) return $eb.message('error','请选择门店营业时间');
  250. // 检查自提字段
  251. if(that.form.is_pick === undefined || that.form.is_pick === null) {
  252. return $eb.message('error','请选择是否支持门店自提');
  253. }
  254. var index = layer.load(1, {
  255. shade: [0.5,'#fff']
  256. });
  257. $eb.axios.post('{:Url("save")}'+(that.id ? '?id='+that.id : ''),that.form).then(function (res) {
  258. layer.close(index);
  259. layer.msg(res.data.msg);
  260. if(res.data.data.id) that.id=res.data.data.id;
  261. }).catch(function (err) {
  262. console.log(err);
  263. layer.close(index);
  264. })
  265. },
  266. selectAdderss:function (data) {
  267. this.form.latlng=data.latlng.lat+','+data.latlng.lng;
  268. }
  269. },
  270. mounted:function () {
  271. window.changeIMG=this.changeIMG;
  272. window.selectAdderss=this.selectAdderss;
  273. }
  274. }).$mount(document.getElementById('store-attr'))
  275. })
  276. </script>
  277. </body>
  278. </html>