| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- <?php /*a:2:{s:54:"D:\phpEnv\www\SCM-API\app\admin\view\addons\index.html";i:1750736984;s:52:"D:\phpEnv\www\SCM-API\app\admin\view\layout\vue.html";i:1750736984;}*/ ?>
- import table from "http://yun.cn/assets/js/components/Table.js";
- import {rand} from "http://yun.cn/assets/js/util.js";
- //生成订单号
- function create_out_trade_no()
- {
- let date=new Date();
- let year=date.getFullYear();
- let month=date.getMonth()+1;
- let day=date.getDate();
- if(day<10){
- day='0'+day;
- }
- let hour=date.getHours();
- if(hour<10){
- hour='0'+hour;
- }
- let minute=date.getMinutes();
- if(minute<10){
- minute='0'+minute;
- }
- let seconds=date.getSeconds();
- if(seconds<10){
- seconds='0'+seconds;
- }
- let r=''+year+month+day+hour+minute+seconds+rand(10000,99999);
- return r;
- }
- function formatTime(seconds)
- {
- let interval = Math.floor(seconds / 31536000);
- if (interval >= 1) {
- return `${interval}年后`;
- }
- interval = Math.floor(seconds / 2592000);
- if (interval >= 1) {
- return `${interval}月后`;
- }
- interval = Math.floor(seconds / 86400);
- if (interval >= 1) {
- return `${interval}天后`;
- }
- interval = Math.floor(seconds / 3600);
- if (interval >= 1) {
- return `${interval}小时后`;
- }
- interval = Math.floor(seconds / 60);
- if (interval >= 1) {
- return `${interval}分钟后`;
- }
- return `${Math.floor(seconds)}秒后`;
- }
- export default{
- components:{'YunTable':table},
- data:{
- extend:{
- index_url: 'addons/index',
- multi_url: 'addons/multi'
- },
- type:Yunqi.data.type,
- tabsValue:'plugin',
- plain:'all',
- columns:[
- {field:"plain",visible:'none',operate:{form:'hidden',value:function (){return Yunqi.app.plain},filter:false}},
- {field:"name",title:"扩展名称"},
- {field:"type",title:"扩展类型",searchList:Yunqi.data.type,operate:false},
- {field:"author",title:"作者"},
- {field:"price",title:"价格",width: 80,formatter:function (data) {
- let tag=Yunqi.formatter.tag;
- if (data) {
- tag.type='primary';
- tag.value='¥'+data;
- }else{
- tag.type='success';
- tag.value='免费';
- }
- return tag;
- }},
- {field:"version",title:"版本号",width: 80},
- {field:"document",title:"说明文档",formatter: function (data){
- if(data) {
- let link=Yunqi.formatter.link;
- link.value = data;
- return link;
- }else{
- return '';
- }
- }},
- {field:"description",title:"简介",width: 300},
- {
- field:"local",
- title:"本地",
- width: 80,
- formatter: function (data){
- let tag=Yunqi.formatter.tag;
- if(data){
- tag.value='是';
- tag.type='success';
- }else{
- tag.value='否';
- tag.type='danger';
- }
- return tag;
- }
- },
- {
- field:"packed",
- title:"打包",
- width: 80,
- formatter:function (data,row){
- if(!row.local){
- return '';
- }
- let tag=Yunqi.formatter.tag;
- if(data){
- tag.value='是';
- tag.type='primary';
- }else{
- tag.value='否';
- tag.type='danger';
- }
- return tag;
- }
- },
- {
- field:"open",
- title:"开放",
- width: 80,
- formatter:function (data,row){
- if(!row.local){
- return '';
- }
- let sw=Yunqi.formatter.switch;
- sw.activeValue=1;
- sw.inactiveValue=0;
- sw.value=row.packed?data:0;
- sw.disabled=true;
- if(row.packed){
- sw.disabled=false;
- }
- return sw;
- }
- },
- {
- field: 'operate',
- title: __('操作'),
- direction:'column',
- width:100,
- action:{
- download:{
- text:__('下载'),
- type:'primary',
- tooltip:false,
- icon:'fa fa-download',
- method:'downloadAddon',
- visible:function (row) {
- return !row.download;
- }
- },
- install:{
- text:__('安装'),
- type:'primary',
- tooltip:false,
- icon:'fa fa-wrench',
- method:'installAddon',
- visible:function (row) {
- return row.download && !row.install;
- }
- },
- pack:{
- text:__('打包'),
- type:'primary',
- tooltip:false,
- icon:'fa fa-briefcase',
- method:'packAddon',
- visible:function (row) {
- return row.download && row.install && !row.packed;
- }
- },
- edit:{
- text:__('编辑'),
- type:'warning',
- tooltip:false,
- icon:'fa fa-edit',
- method:'editAddon',
- visible:function (row) {
- return row.local && row.is_author && !row.packed;
- }
- },
- uninstall:{
- text:__('卸载'),
- type:'danger',
- tooltip:false,
- icon:'fa fa-remove',
- method:'uninstallAddon',
- visible:function (row) {
- return row.install && row.packed;
- }
- },
- remove:{
- text:__('删除'),
- type:'danger',
- tooltip:false,
- icon:'fa fa-remove',
- method:'delAddon',
- visible:function (row) {
- return row.download && !row.install;
- }
- },
- },
- }
- ],
- buyDialog:{
- show:false,
- out_trade_no:'',
- transaction_id:'',
- expire_time:0,
- status:0,
- message:'',
- code_url:'',
- row:''
- }
- },
- onLoad:function (){
- setInterval(()=>{
- this.checkPayStatus();
- },2000)
- },
- methods:{
- changePlain:function (plain) {
- this.plain = plain;
- this.$refs.yuntable.submit();
- },
- packAddon:function(row) {
- Yunqi.ajax.post('addons/pack',row).then(res=>{
- this.$refs.yuntable.reload();
- });
- },
- editAddon:function (row){
- let that=this;
- Yunqi.api.open({
- title: __('修改本地扩展'),
- url: 'addons/create?id='+row.id,
- icon:'fa fa-edit',
- close:function (r) {
- if(r){
- that.$refs.yuntable.reload();
- }
- }
- });
- },
- downloadAddon:function(row){
- if(row.price>0){
- this.buyDialog.out_trade_no=create_out_trade_no();
- this.buyDialog.code_url=Yunqi.config.baseUrl+'addons/payCode?key='+row.key+'&out_trade_no='+this.buyDialog.out_trade_no;
- this.buyDialog.show=true;
- this.buyDialog.row=row;
- }else{
- Yunqi.ajax.post('addons/download', row).then(res=>{
- this.$refs.yuntable.reload();
- });
- }
- },
- payDownload:function (){
- let postdata={...this.buyDialog.row,transaction_id:this.buyDialog.transaction_id}
- Yunqi.ajax.post('addons/download',postdata).then(res=>{
- this.closeBuyDialog();
- this.$refs.yuntable.reload();
- });
- },
- checkPayStatus:function (){
- if(this.buyDialog.show){
- Yunqi.ajax.get('addons/checkPayStatus',{out_trade_no:this.buyDialog.out_trade_no,key:this.buyDialog.row.key}).then(res=>{
- if(res){
- this.buyDialog.transaction_id=res.transaction_id;
- this.buyDialog.expire_time=res.expire_time;
- this.buyDialog.message='支付成功';
- this.buyDialog.status=1;
- }
- });
- }
- },
- checkTransactionId:function (){
- let postdata={
- pack:this.buyDialog.row.pack,
- transaction_id:this.buyDialog.transaction_id
- };
- Yunqi.ajax.get('addons/checkTransactionId',postdata).then(res=>{
- this.buyDialog.status=res.status;
- this.buyDialog.expire_time=res.expire_time;
- if(res.status==0){
- this.buyDialog.message='交易单号不存在';
- }else{
- if(res.expire_time>0){
- this.buyDialog.message=formatTime(res.expire_time)+'过期';
- }else{
- this.buyDialog.message='交易单号已经过期';
- }
- }
- });
- },
- closeBuyDialog:function () {
- this.buyDialog={
- show:false,
- out_trade_no:'',
- transaction_id:'',
- expire_time:0,
- status:0,
- message:'',
- code_url:'',
- row:''
- }
- },
- installAddon:function(row)
- {
- Yunqi.ajax.post('addons/install',{key:row.key}).then(res=>{
- this.$refs.yuntable.reload();
- });
- },
- uninstallAddon:function(row)
- {
- let that=this;
- Yunqi.api.open({
- title: __('卸载扩展'),
- url: 'addons/uninstall?key='+row.key,
- icon:'fa fa-remove',
- close:function (r) {
- if(r){
- that.$refs.yuntable.reload();
- }
- }
- });
- },
- delAddon:function (row){
- let that=this;
- Yunqi.confirm('删除扩展将会清空掉所有文件,重新下载扩展可能会再次收取费用,你确定要删除吗?','提醒').then(res=>{
- Yunqi.ajax.post('addons/del',{key:row.key}).then(res=>{
- that.$refs.yuntable.reload();
- });
- });
- },
- createAddon:function(){
- let that=this;
- Yunqi.api.open({
- title: __('创建本地扩展'),
- url: 'addons/create',
- icon:'fa fa-plus',
- close:function (r) {
- if(r){
- that.$refs.yuntable.reload();
- }
- }
- });
- }
- }
- }
|