brand.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. $(function () {
  2. var types = {
  3. 0:'其他',
  4. 1:'生活',
  5. 2:'文化',
  6. 3:'工业',
  7. }
  8. $("#jqGrid").Grid({
  9. url: '../brand/list',
  10. rownumWidth:60,
  11. colModel: [{
  12. label: 'id', name: 'id', index: 'id', key: true, hidden: true
  13. }, {
  14. label: '店铺名称', name: 'name', index: 'name', width: 80
  15. },
  16. {
  17. label: '类型', name: 'type', index: 'type', width: 80,formatter: function (value) {
  18. return types[value] || '-'
  19. }
  20. },
  21. {
  22. label: '场景地址', name: 'sceneUrl', index: 'scene_url', width: 140
  23. },
  24. {
  25. label: '店铺封面',align:'center', name: 'listPicUrl', index: 'list_pic_url', width: 120, formatter: function (value) {
  26. return transImg(value,100,'auto');
  27. }
  28. },
  29. {
  30. label: '分享图', align:'center', name: 'newPicUrl', index: 'new_pic_url', width: 120, formatter: function (value) {
  31. return transImg(value,100,'auto');
  32. }
  33. },
  34. // {
  35. // label: '描述', name: 'simpleDesc', index: 'simple_desc', width: 80
  36. // },
  37. // {
  38. // label: '缩略图', align:'center',name: 'picUrl', index: 'pic_url', width: 120, formatter: function (value) {
  39. // return transImg(value,100,'auto');
  40. // }
  41. // },
  42. {
  43. label: '排序', name: 'sortOrder', index: 'sort_order', width: 80
  44. },
  45. {
  46. label: '显示', name: 'isShow', index: 'is_show', width: 80, formatter: function (value) {
  47. return transIsNot(value)
  48. }
  49. },
  50. // {
  51. // label: '展示价格', name: 'floorPrice', index: 'floor_Price', width: 80
  52. // },
  53. // {
  54. // label: '封面图',align:'center', name: 'appListPicUrl', index: 'app_list_pic_url', width: 120, formatter: function (value) {
  55. // return transImg(value,100,'auto');
  56. // }
  57. // },
  58. // {
  59. // label: '新店铺', name: 'isNew', index: 'is_new', width: 80, formatter: function (value) {
  60. // return transIsNot(value)
  61. // }
  62. // },
  63. // {
  64. // label: '新店铺排序', name: 'newSortOrder', index: 'new_sort_order', width: 80
  65. // }
  66. ]
  67. });
  68. });
  69. const validateSceneUrlCheck = function (rule, value, callback){
  70. console.log(value)
  71. var link1 ='https://test.4dkankan.com/eShopMobile.html?m='
  72. var link2 ='https://www.4dkankan.com/eShopMobile.html?m='
  73. if (value === ''||!value) {
  74. callback(new Error('场景地址不能为空'));
  75. } else if(!~value.indexOf(link1)&&!~value.indexOf(link2)){
  76. callback(new Error('场景地址需为'+link2+'或'+link1));
  77. } else {
  78. callback();
  79. }
  80. };
  81. var vm = new Vue({
  82. el: '#rrapp',
  83. data: {
  84. showList: true,
  85. title: null,
  86. brand: {listPicUrl: '',type:0, picUrl: '', appListPicUrl: '', newPicUrl: '', isShow: 1, isNew: 0},
  87. ruleValidate: {
  88. name: [
  89. {required: true, message: '店铺名称不能为空', trigger: 'blur'}
  90. ],
  91. listPicUrl: [
  92. {required: true, message: '图片不能为空', trigger: 'blur'}
  93. ],
  94. simpleDesc: [
  95. {required: true, message: '描述不能为空', trigger: 'blur'}
  96. ],
  97. // sceneUrl: [
  98. // {required: true, validator: validateSceneUrlCheck, trigger: 'blur'}
  99. // ],
  100. picUrl: [
  101. {required: true, message: '缩略图不能为空', trigger: 'blur'}
  102. ]
  103. },
  104. q: {
  105. name: '',
  106. type:''
  107. },
  108. typeList:[
  109. {
  110. id:0,
  111. name:'其他'
  112. },
  113. {
  114. id:1,
  115. name:'生活'
  116. },
  117. {
  118. id:2,
  119. name:'文化'
  120. },
  121. {
  122. id:3,
  123. name:'工业'
  124. },
  125. ],
  126. phoneNum: "",
  127. password: "",
  128. index:''
  129. },
  130. methods: {
  131. addSceneLink: function () {
  132. openWindow({
  133. title: "四维看看账号",
  134. area: ['400px', '400px'],
  135. content: jQuery("#loginLayer")
  136. });
  137. },
  138. query: function () {
  139. vm.reload();
  140. },
  141. add: function () {
  142. vm.showList = false;
  143. vm.title = "新增";
  144. vm.brand = {listPicUrl: '',type:0,sceneUrl:'', picUrl: '', appListPicUrl: '', newPicUrl: '', isShow: 1, isNew: 0};
  145. },
  146. update: function (event) {
  147. var id = getSelectedRow("#jqGrid");
  148. if (id == null) {
  149. return;
  150. }
  151. vm.showList = false;
  152. vm.title = "修改";
  153. vm.getInfo(id)
  154. },
  155. saveOrUpdate: function (event) {
  156. var url = vm.brand.id == null ? "../brand/save" : "../brand/update";
  157. Ajax.request({
  158. type: "POST",
  159. url: url,
  160. contentType: "application/json",
  161. params: JSON.stringify(vm.brand),
  162. successCallback: function () {
  163. alert('操作成功', function (index) {
  164. vm.reload();
  165. });
  166. }
  167. });
  168. },
  169. del: function (event) {
  170. var ids = getSelectedRows("#jqGrid");
  171. if (ids == null) {
  172. return;
  173. }
  174. confirm('确定要删除选中的记录?', function () {
  175. Ajax.request({
  176. type: "POST",
  177. url: "../brand/delete",
  178. contentType: "application/json",
  179. params: JSON.stringify(ids),
  180. successCallback: function () {
  181. alert('操作成功', function (index) {
  182. vm.reload();
  183. });
  184. }
  185. });
  186. });
  187. },
  188. getInfo: function (id) {
  189. Ajax.request({
  190. url: "../brand/info/" + id,
  191. async: true,
  192. successCallback: function (r) {
  193. vm.brand = r.brand;
  194. }
  195. });
  196. },
  197. reload: function (event) {
  198. vm.showList = true;
  199. var page = $("#jqGrid").jqGrid('getGridParam', 'page');
  200. $("#jqGrid").jqGrid('setGridParam', {
  201. postData: {'name': vm.q.name,'type': vm.q.type},
  202. page: page
  203. }).trigger("reloadGrid");
  204. vm.handleReset('formValidate');
  205. },
  206. handleSuccessListPicUrl: function (res, file) {
  207. vm.brand.listPicUrl = file.response.url;
  208. vm.brand.appListPicUrl = file.response.url;
  209. },
  210. handleSuccessPicUrl: function (res, file) {
  211. vm.brand.picUrl = file.response.url;
  212. },
  213. handleSuccessAppListPicUrl: function (res, file) {
  214. vm.brand.appListPicUrl = file.response.url;
  215. },
  216. handleSuccessNewPicUrl: function (res, file) {
  217. vm.brand.newPicUrl = file.response.url;
  218. },
  219. handleFormatError: function (file) {
  220. this.$Notice.warning({
  221. title: '文件格式不正确',
  222. desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
  223. });
  224. },
  225. handleMaxSize: function (file) {
  226. this.$Notice.warning({
  227. title: '超出文件大小限制',
  228. desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
  229. });
  230. },
  231. eyeImageListPicUrl: function () {
  232. var url = vm.brand.listPicUrl;
  233. eyeImage(url);
  234. },
  235. eyeImagePicUrl: function () {
  236. var url = vm.brand.picUrl;
  237. eyeImage(url);
  238. },
  239. eyeImageAppListPicUrl: function () {
  240. var url = vm.brand.appListPicUrl;
  241. eyeImage(url);
  242. },
  243. eyeImageNewPicUrl: function () {
  244. var url = vm.brand.newPicUrl;
  245. eyeImage(url);
  246. },
  247. handleSubmit: function (name) {
  248. handleSubmitValidate(this, name, function () {
  249. vm.saveOrUpdate()
  250. });
  251. },
  252. handleReset: function (name) {
  253. handleResetForm(this, name);
  254. }
  255. },
  256. mounted () {
  257. window.addEventListener('message', function(e) {
  258. var data = e.data;
  259. console.log(data);
  260. if (data==='close') {
  261. layer.closeAll()
  262. }
  263. if (data.website) {
  264. vm.brand.sceneUrl = data.website || ''
  265. console.log(vm.brand.sceneUrl);
  266. layer.closeAll()
  267. }
  268. }, false);
  269. }
  270. });