purchased.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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: 110px;
  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-status{
  70. position: absolute;
  71. top: 0px;
  72. right: 0px;
  73. z-index: 10;
  74. }
  75. .status-expire {
  76. background-color: #f4f4f5;
  77. color: #909399;
  78. }
  79. .status-uninstall {
  80. background-color: #fdf6ec;
  81. color: #e6a23c;
  82. }
  83. .status-tobeinstall {
  84. background-color: #f0f9eb;
  85. color: #67c23a;
  86. }
  87. .status-box {
  88. height: 24px;
  89. padding: 4px 10px;
  90. display: inline-block;
  91. font-size: 12px;
  92. }
  93. .question_icon{
  94. /*position: absolute;*/
  95. /*top: 6px;*/
  96. /*right: 6px;*/
  97. width: 20px;
  98. height: 20px;
  99. z-index: 10;
  100. display: inline;
  101. }
  102. .question_icon i{
  103. font-size: 17px;
  104. color: #BFBFBF;
  105. }
  106. .operate-btn {
  107. position: relative;
  108. bottom: 8px;
  109. left: 10px;
  110. }
  111. .expire-txt {
  112. font-size: 12px;
  113. color: #A6A6A6;
  114. }
  115. </style>
  116. <div id="app" v-cloak>
  117. <template>
  118. <div v-for="(item,its) in addons" :key="its">
  119. <h3 class="list-title">
  120. {{item.title}}
  121. </h3>
  122. <el-row v-if="item.list" class="plugin-list" v-loading="loading">
  123. <template v-for="(plugin,index) in item.list">
  124. <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
  125. <div class="plugin-item">
  126. <div flex="dir:left box:first">
  127. <div style="margin-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">
  137. {{plugin.title}}
  138. <!-- 使用教程 -->
  139. <div class="question_icon" @click.stop="courseurl(plugin.course_url)">
  140. <el-tooltip class="" effect="dark" :content="prompt" placement="bottom">
  141. <i class="el-icon-question"></i>
  142. </el-tooltip>
  143. </div>
  144. </div>
  145. <div flex="box:last" style="font-size: 12px;">
  146. <com-ellipsis :line="1" :text="plugin.brief_introduction"></com-ellipsis>
  147. <div>
  148. <el-button plain v-if="plugin.is_renew == -1" size="mini" class="operate-btn" @click="handle('renew', plugin)">续费</el-button>
  149. <el-button plain v-else-if="plugin.addons_status == 1" size="mini" class="operate-btn" @click="handle('set', plugin)">安装</el-button>
  150. <el-button plain v-else-if="plugin.addons_status == 2 || plugin.addons_status == 0" size="mini" class="operate-btn" @click="handle('detail', plugin)">详情</el-button>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. <div class="expire-txt" style="height: 30px; line-height: 30px;">
  156. <span style="margin-right: 10px;">到期时间:{{ plugin.expire_time == -1 ? '永久有效' : formatDate(plugin.expire_time) }} </span>
  157. <el-button style="font-size: 12px; color: #f56c6c;" type="text" v-if="plugin.expire_time > 0 && plugin.expire_time <= now_time" @click="handle('renew', plugin)">已过期 立即续费>></el-button>
  158. <el-button style="font-size: 12px; color: #f56c6c;" type="text" v-else-if="plugin.soon_expire == 1" @click="handle('renew', plugin)">即将过期 立即续费>></el-button>
  159. </div>
  160. <div v-if="plugin.addons_status == -1" class="item-status status-expire">已过期</div>
  161. <div v-if="plugin.addons_status == 0" class="item-status status-uninstall">已卸载</div>
  162. <div v-if="plugin.addons_status == 1" class="item-status status-tobeinstall">待安装</div>
  163. </div>
  164. </el-col>
  165. </template>
  166. </el-row>
  167. </div>
  168. <el-dialog
  169. title="应用安装"
  170. :visible.sync="dialogVisible"
  171. width="30%"
  172. style="margin-top:25vh;"
  173. :close-on-click-modal="false"
  174. v-loading="dialogLoading">
  175. <span>是否继续安装此应用</span>
  176. <span slot="footer" class="dialog-footer">
  177. <el-button @click="dialogVisible = false">取 消</el-button>
  178. <el-button type="primary" @click="handle('install', plugin_info)">确 定</el-button>
  179. </span>
  180. </el-dialog>
  181. </template>
  182. </div>
  183. <script>
  184. new Vue({
  185. el: '#app',
  186. data() {
  187. return {
  188. loading: false,
  189. dialogVisible: false,
  190. dialogLoading: false,
  191. prompt: '使用教程',
  192. addons: [],
  193. now_time: 0,
  194. plugin_info: {},
  195. };
  196. },
  197. created() {
  198. this.getList();
  199. },
  200. methods: {
  201. getList() {
  202. this.loading = true;
  203. request({
  204. params: {
  205. r: 'mall/addons/purchased',
  206. },
  207. method: 'post',
  208. data: {}
  209. }).then(e => {
  210. this.loading = false;
  211. if (e.data.code === 0) {
  212. this.handleData(e.data.data.addons_list)
  213. this.addons = e.data.data.addons_list
  214. this.now_time = e.data.data.now_time
  215. } else {
  216. this.$message.error(e.data.msg);
  217. }
  218. }).catch(e => {
  219. });
  220. },
  221. handleData(data){
  222. if(data){
  223. for(let cate in data){
  224. if(data[cate].list){
  225. for(let item in data[cate].list){
  226. data[cate].list[item].default_cover = _diy_img_prefix+'/static/addons/icon/'+data[cate].list[item].name+'.png'
  227. }
  228. }
  229. }
  230. }
  231. },
  232. entryDetail(addonsName) {
  233. navigateTo({r: 'mall/addons/detail', name: addonsName});
  234. },
  235. courseurl(url){
  236. if(url){
  237. window.open(url, '_blank')
  238. }else{
  239. this.$message.warning('未设置教程链接');
  240. }
  241. },
  242. formatDate: function (value) {
  243. let date = new Date(value * 1000);
  244. let y = date.getFullYear();
  245. let MM = date.getMonth() + 1;
  246. MM = MM < 10 ? ('0' + MM) : MM;
  247. let d = date.getDate();
  248. d = d < 10 ? ('0' + d) : d;
  249. return y + '-' + MM + '-' + d;
  250. },
  251. entryPlugin(addon) {
  252. var name = addon.name.replace(/([A-Z])/g,"-$1").toLowerCase();
  253. name = name.substr(1, name.length);
  254. if (addon.url) {
  255. navigateTo({r: addon.url});
  256. } else {
  257. navigateTo({r: name + '/default/index'});
  258. }
  259. },
  260. // 操作处理
  261. handle(type, data = null) {
  262. let id = data ? parseInt(data.id) : '';
  263. switch (type) {
  264. case 'renew':// 编辑
  265. this.entryDetail(data.name);
  266. break;
  267. case 'set':// 设置应用值
  268. this.plugin_info = data;
  269. this.dialogVisible = true;
  270. break;
  271. case 'install':// 安装应用
  272. this.dialogLoading = true;
  273. params = {
  274. name: data.name,
  275. };
  276. this.send(params, 'mall/addons/install', (resp) => {
  277. if (resp.code == 0) {
  278. this.getList();
  279. }
  280. });
  281. this.dialogVisible = false;
  282. this.dialogLoading = false;
  283. break;
  284. case 'detail':// 编辑
  285. params = {
  286. r: 'mall/addons/detail'
  287. };
  288. params = Object.assign(params, {
  289. name: data.name
  290. });
  291. navigateTo(params);
  292. break;
  293. }
  294. },
  295. send(params,url,callback) {
  296. let self = this;
  297. request({
  298. params: {
  299. r: url,
  300. },
  301. method: 'post',
  302. data: params
  303. }).then(e => {
  304. if (e.data.code == 0) {
  305. self.$message.success(e.data.msg);
  306. } else {
  307. self.$message.error(e.data.msg);
  308. }
  309. if (callback) callback(e.data);
  310. }).catch(e => {
  311. console.log(e);
  312. });
  313. },
  314. }
  315. });
  316. </script>