detail.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. /**
  3. * @link:http://www.gdqijianshi.com/
  4. * @copyright: Copyright (c) 2020 广东七件事集团
  5. * Created by PhpStorm
  6. * Author: ganxiaohao
  7. * Date: 2020-05-26
  8. * Time: 14:11
  9. */
  10. ?>
  11. <style>
  12. .plugin-icon {
  13. display: block;
  14. width: 130px;
  15. height: 130px;
  16. margin-right: 20px;
  17. border-radius: 3px;
  18. }
  19. .local-tag {
  20. background: #E6A23C;
  21. color: #fff;
  22. padding: 0 4px;
  23. height: 19px;
  24. line-height: 19px;
  25. font-size: 12px;
  26. }
  27. .header-box {
  28. padding: 20px;
  29. background-color: #fff;
  30. margin-bottom: 10px;
  31. border-top-left-radius: 4px;
  32. border-top-right-radius: 4px;
  33. }
  34. .el-card, .el-message {
  35. border-radius: 0;
  36. border-bottom-left-radius: 4px;
  37. border-bottom-right-radius: 4px;
  38. }
  39. .el-card__header {
  40. padding: 18px 20px 0 20px;
  41. }
  42. .el-radio {
  43. margin-right: 0px;
  44. }
  45. </style>
  46. <div id="app" v-cloak>
  47. <div slot="header" class="header-box">
  48. <el-breadcrumb separator="/">
  49. <el-breadcrumb-item><span style="color: #409EFF;cursor: pointer"
  50. @click="$navigate({r:'mall/addons/index'})">我的应用</span></el-breadcrumb-item>
  51. <el-breadcrumb-item>应用详情</el-breadcrumb-item>
  52. </el-breadcrumb>
  53. </div>
  54. <el-card shadow="never" v-loading="loading" style="border:0">
  55. <template v-if="plugin">
  56. <div slot="header" class="form-body">
  57. <div flex="dir:left box:first cross:center">
  58. <!-- 应用图标 -->
  59. <div>
  60. <img :src="plugin.cover ? plugin.cover : plugin.default_cover" class="plugin-icon">
  61. </div>
  62. <!-- 应用内容 -->
  63. <div>
  64. <p style="margin-bottom: 10px; font-size: 16px; font-weight: bold;">{{plugin.title}}</p>
  65. <p style="margin-bottom: 10px">
  66. <span style="color: #909399; font-size: 12px;">{{ plugin.brief_introduction }}</span>
  67. </p>
  68. <p style="margin-bottom: 10px">
  69. 价格:<span style="color: #FF1C1C; font-size: 12px;">{{ default_price == 0 ? '免费' : '¥' + default_price }}</span>
  70. </p>
  71. <p>
  72. 周期:
  73. <el-radio v-model="setting_index" size="mini"
  74. v-for="(item, index) in price_setting_arr"
  75. :key="index"
  76. :label="index"
  77. border
  78. @change="handle('price', item, index)">
  79. {{ item.unit == 0 ? '永久' : item.duration }}
  80. {{ item.unit == 0 ? '' : unit_arr[item.unit] }}
  81. </el-radio>
  82. </p>
  83. <p v-if="plugin.expire_time" style="margin-top: 8px; font-size: 12px;">
  84. <span style="color: #909399;">期限:{{ plugin.expire_time == -1 ? '永久有效' : formatDate(plugin.expire_time) }}</span>
  85. <span v-if="plugin.expire_time > 0 && plugin.expire_time <= plugin.now_time" style="color: #f56c6c;"> 已过期</span>
  86. </p>
  87. </div>
  88. </div>
  89. <div style="padding-left: 146px; margin-top: 20px;">
  90. <el-button type="primary" size="small" v-if="plugin.allow_install == 1" :loading="installLoading" @click="handle('install', plugin)">安装</el-button>
  91. <el-button type="warning" size="small" v-if="plugin.allow_uninstall == 1" :loading="uninstallLoading" @click="handle('uninstall', plugin)">卸载</el-button>
  92. <el-button type="primary" size="small" v-if="plugin.expire_time != -1" @click="handle('buy', plugin)">{{ plugin.is_renew == 1 ? '续费' : '立即购买' }}</el-button>
  93. </div>
  94. </div>
  95. <div style="font-size: 16px; margin-bottom: 20px;">应用详情</div>
  96. <div v-html="plugin.description"></div>
  97. </template>
  98. </el-card>
  99. </div>
  100. <script>
  101. new Vue({
  102. el: '#app',
  103. data() {
  104. return {
  105. loading: true,
  106. plugin: null,
  107. installLoading: false,
  108. uninstallLoading: false,
  109. default_price: '0',
  110. price_setting_arr: [],
  111. setting_index: 0,
  112. unit_arr: {
  113. 1: '个月',
  114. 2: '年',
  115. },
  116. };
  117. },
  118. created() {
  119. this.loadData();
  120. },
  121. methods: {
  122. loadData() {
  123. this.loading = true;
  124. this.$request({
  125. params: {
  126. r: 'mall/addons/detail',
  127. name: getQuery('name'),
  128. },
  129. }).then(e => {
  130. this.loading = false;
  131. if (e.data.code === 0) {
  132. this.plugin = e.data.data;
  133. this.price_setting_arr = e.data.data.price_setting;
  134. this.default_price = this.price_setting_arr[0]['money'];
  135. this.plugin.default_cover = _diy_img_prefix+'/static/addons/icon/'+this.plugin.name+'.png';
  136. }
  137. }).catch(e => {
  138. });
  139. },
  140. // 操作处理
  141. handle(type, data = null, extra_data = null) {
  142. let id = data ? parseInt(data.id) : '';
  143. switch (type) {
  144. case 'price':// 改变价格
  145. this.default_price = data.money;
  146. this.setting_index = extra_data;
  147. break;
  148. case 'buy':// 续费或购买
  149. params = {
  150. r: '/mall/addons/confirm-order'
  151. };
  152. params = Object.assign(params, {
  153. name: data.name,
  154. setting_index: this.setting_index,
  155. });
  156. navigateTo(params);
  157. break;
  158. case 'install':// 安装应用
  159. this.installLoading = true;
  160. params = {
  161. name: data.name,
  162. };
  163. this.send(params, 'mall/addons/install', (resp) => {
  164. if (resp.code == 0) this.loadData();
  165. });
  166. this.installLoading = false;
  167. break;
  168. case 'uninstall':// 卸载应用
  169. this.uninstallLoading = true;
  170. params = {
  171. name: data.name,
  172. };
  173. this.$confirm('即将卸载该应用, 是否继续?', '警告', {
  174. type: 'warning'
  175. }).then(() => {
  176. this.send(params, 'mall/addons/uninstall', (resp) => {
  177. if (resp.code == 0) this.loadData();
  178. });
  179. })
  180. this.uninstallLoading = false;
  181. break;
  182. }
  183. },
  184. send(params,url,callback) {
  185. let self = this;
  186. request({
  187. params: {
  188. r: url,
  189. },
  190. method: 'post',
  191. data: params
  192. }).then(e => {
  193. if (e.data.code == 0) {
  194. self.$message.success(e.data.msg);
  195. } else {
  196. self.$message.error(e.data.msg);
  197. }
  198. if (callback) callback(e.data);
  199. }).catch(e => {
  200. console.log(e);
  201. });
  202. },
  203. formatDate: function (value) {
  204. let date = new Date(value * 1000);
  205. let y = date.getFullYear();
  206. let MM = date.getMonth() + 1;
  207. MM = MM < 10 ? ('0' + MM) : MM;
  208. let d = date.getDate();
  209. d = d < 10 ? ('0' + d) : d;
  210. return y + '-' + MM + '-' + d;
  211. },
  212. }
  213. });
  214. </script>