index.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <style>
  2. .list-title {
  3. font-weight: 400;
  4. font-size: 18px;
  5. }
  6. .plugin-list {
  7. margin: 0 0 0 -20px;
  8. }
  9. .plugin-item {
  10. position: relative;
  11. border: 1px solid #ebebeb;
  12. background: #fff;
  13. padding: 20px;
  14. margin: 0 0 20px 20px;
  15. transition: 250ms;
  16. height: 97px;
  17. }
  18. .plugin-item .display-name {
  19. margin-bottom: 10px;
  20. transition: 250ms;
  21. font-weight: bold;
  22. }
  23. .plugin-item .el-tooltip {
  24. color: #BFBFBF;
  25. }
  26. .plugin-item:hover {
  27. cursor: pointer;
  28. border-color: #bfddff;
  29. }
  30. .plugin-item:hover .display-name {
  31. color: #409EFF;
  32. font-weight: bold;
  33. }
  34. .plugin-item .plugin-option-btn {
  35. height: 25px;
  36. width: 25px;
  37. font-size: 12px;
  38. padding: 0;
  39. }
  40. .plugin-item .detail-option.detail-option {
  41. color: #909399;
  42. background: #F2F6FC;
  43. }
  44. .plugin-item .detail-option:hover {
  45. color: #fff;
  46. background: #909399;
  47. }
  48. .plugin-item .name{
  49. white-space:nowrap;
  50. overflow:hidden;
  51. text-overflow:ellipsis;
  52. font-size: 12px;
  53. }
  54. .plugin-item .item-status{
  55. position: absolute;
  56. z-index: 10;
  57. top: 0;
  58. right: 0;
  59. width: 64px;
  60. height: 20px;
  61. opacity: 1;
  62. border-radius: 0px 0px 0px 5px;
  63. font-size: 11px;
  64. line-height: 20px;
  65. font-family: Microsoft YaHei;
  66. font-weight: 400;
  67. text-align: center;
  68. }
  69. .plugin-item .status0{
  70. background-color: #E8EAEC;
  71. color: #9398A4;
  72. }
  73. .plugin-item .status2{
  74. background-color: #fef0f0;
  75. color: #f56c6c;
  76. }
  77. .question_icon{
  78. position: absolute;
  79. top: 6px;
  80. right: 6px;
  81. width: 20px;
  82. height: 20px;
  83. z-index: 10;
  84. }
  85. .question_icon i{
  86. font-size: 17px;
  87. color: #BFBFBF;
  88. }
  89. .icon-item + .icon-item {
  90. margin-left: 5px;
  91. }
  92. </style>
  93. <div id="app" v-cloak>
  94. <template>
  95. <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  96. <div slot="header">
  97. <div class="input-item" style="width: 300px;">
  98. <el-input @keyup.enter.native="getList" size="small" placeholder="请输入搜索应用名称" v-model="search.keyword"
  99. clearable @clear="toSearch">
  100. <el-button slot="append" icon="el-icon-search" @click="toSearch"></el-button>
  101. </el-input>
  102. </div>
  103. </div>
  104. </el-card>
  105. <div v-for="(item,its) in addons" :key="its">
  106. <h3 class="list-title">
  107. {{item.title}}
  108. </h3>
  109. <el-row v-if="item.list" class="plugin-list" v-loading="loading">
  110. <template v-for="(plugin,index) in item.list">
  111. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4">
  112. <div flex="dir:left box:first" class="plugin-item" @click="entryPlugin(plugin)">
  113. <div class="question_icon" >
  114. <!-- 应用置顶 -->
  115. <el-tooltip class="icon-item" effect="dark" content="应用置顶" placement="bottom" v-if="plugin.is_top == 0">
  116. <i class="el-icon-top" @click.stop="toTop(plugin.name)"></i>
  117. </el-tooltip>
  118. <!-- 取消应用置顶 -->
  119. <el-tooltip class="icon-item" effect="dark" content="取消应用置顶" placement="bottom" v-if="plugin.is_top == 1">
  120. <i class="el-icon-bottom" @click.stop="toBottom(plugin.name)"></i>
  121. </el-tooltip>
  122. <!-- 教程 -->
  123. <el-tooltip class="icon-item" effect="dark" :content="prompt" placement="bottom" v-if="plugin.name">
  124. <i @click.stop="courseurl(plugin.course_url)" class="el-icon-question"></i>
  125. </el-tooltip>
  126. </div>
  127. <div style="padding-right: 12px;">
  128. <!--<img style="width: 50px;height: 50px;display: block;" :src="plugin.cover">-->
  129. <el-image style="width: 50px;height: 50px;border-radius: 5px;" :src="plugin.cover">
  130. <div slot="error" class="image-slot">
  131. <com-image :src="plugin.default_cover"></com-image>
  132. </div>
  133. </el-image>
  134. </div>
  135. <div style="width: 53%">
  136. <div class="display-name">{{plugin.title}}</div>
  137. <div flex="box:last" >
  138. <com-ellipsis :line="1" :text="plugin.brief_introduction"></com-ellipsis>
  139. <div v-if="plugin.name">
  140. <el-button class="plugin-option-btn detail-option"
  141. type="text"
  142. icon="el-icon-more"
  143. circle
  144. @click.stop="entryDetail(plugin.name)">
  145. </el-button>
  146. </div>
  147. </div>
  148. </div>
  149. <div v-if="plugin.status == 0" class="item-status status0">未安装</div>
  150. <div v-if="plugin.status == 2" class="item-status status2">已过期</div>
  151. </div>
  152. </el-col>
  153. </template>
  154. </el-row>
  155. </div>
  156. </template>
  157. </div>
  158. <script>
  159. new Vue({
  160. el: '#app',
  161. data() {
  162. return {
  163. loading: false,
  164. prompt: '使用教程',
  165. addons: [],
  166. search: {
  167. keyword: null
  168. }
  169. };
  170. },
  171. created() {
  172. this.getList();
  173. },
  174. methods: {
  175. toSearch() {
  176. this.getList();
  177. },
  178. getList() {
  179. this.loading = true;
  180. let params = {
  181. r: 'mall/addons/index',
  182. };
  183. params = Object.assign(params, this.search);
  184. request({
  185. params: params,
  186. method: 'get',
  187. }).then(e => {
  188. this.loading = false;
  189. if (e.data.code === 0) {
  190. this.handleData(e.data.data)
  191. this.addons = e.data.data
  192. } else {
  193. this.$message.error(e.data.msg);
  194. }
  195. }).catch(e => {
  196. });
  197. },
  198. handleData(data){
  199. if(data){
  200. for(let cate in data){
  201. if(data[cate].list){
  202. for(let item in data[cate].list){
  203. data[cate].list[item].default_cover = _diy_img_prefix+'/static/addons/icon/'+data[cate].list[item].name+'.png'
  204. }
  205. }
  206. }
  207. }
  208. },
  209. entryDetail(addonsName) {
  210. navigateTo({r: 'mall/addons/detail', name: addonsName});
  211. },
  212. courseurl(url){
  213. if(url){
  214. window.open(url, '_blank');
  215. }else{
  216. this.$message.warning('未设置教程链接');
  217. }
  218. },
  219. entryPlugin(addon) {
  220. if(addon.name){
  221. var name = addon.name.replace(/([A-Z])/g,"-$1").toLowerCase();
  222. name = name.substr(1, name.length);
  223. if (addon.url) {
  224. navigateTo({r: addon.url});
  225. } else {
  226. navigateTo({r: name + '/default/index'});
  227. }
  228. }else{
  229. window.open(addon.url, "_blank");
  230. }
  231. },
  232. /**
  233. * 设置应用置顶
  234. */
  235. toTop (name) {
  236. this.$confirm('是否把该应用进行置顶?', '提示', {type: 'notice'}).then(() => {
  237. request({
  238. params: {
  239. r: 'mall/addons/to-top',
  240. },
  241. method: 'post',
  242. data: {
  243. name: name,
  244. }
  245. }).then(e => {
  246. if (e.data.code == 0) {
  247. this.$message.success('设置成功')
  248. localStorage.setItem('mall_header_data', '');
  249. setTimeout(() => {
  250. location.reload()
  251. }, 1500)
  252. } else {
  253. this.$message.warning(e.data.msg)
  254. }
  255. }).catch(e => {
  256. this.$message.warning('设置置顶失败')
  257. })
  258. })
  259. },
  260. /**
  261. * 取消应用置顶
  262. */
  263. toBottom (name) {
  264. this.$confirm('是否把该应用取消置顶?', '提示', {type: 'notice'}).then(() => {
  265. request({
  266. params: {
  267. r: 'mall/addons/to-bottom',
  268. },
  269. method: 'post',
  270. data: {
  271. name: name,
  272. }
  273. }).then(e => {
  274. if (e.data.code == 0) {
  275. this.$message.success('设置成功')
  276. localStorage.setItem('mall_header_data', '');
  277. setTimeout(() => {
  278. location.reload()
  279. }, 1500)
  280. } else {
  281. this.$message.warning(e.data.msg)
  282. }
  283. }).catch(e => {
  284. this.$message.warning('设置置顶失败')
  285. })
  286. })
  287. }
  288. }
  289. });
  290. </script>