OpenedProduct.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <!-- 用户已开通产品 By_liucf -->
  2. <template>
  3. <div class="opened">
  4. <MiniTitle>
  5. <div slot="mini" class="miniTit">
  6. <span>机构中心——已经开通的产品</span>
  7. </div>
  8. </MiniTitle>
  9. <div class="main-box">
  10. <!-- <div class="box" v-for="(item,index) in product" :key="item.id"> -->
  11. <div v-for="(item,index) in product" :key="item.id" :class="['box',{'grayCol':item.isExpired || item.serviceStatus ==0 || item.openedServiceStatus==0}]">
  12. <h3>{{item.name}}</h3>
  13. <p class="expired">产品服务有效期:
  14. <span v-if="item.isExpired" class="red">{{item.startTime|dataFormat}} ~ {{item.endTime|dataFormat}} (已过期)</span>
  15. <span v-else>{{item.startTime|dataFormat}} ~ {{item.endTime|dataFormat}}</span>
  16. </p>
  17. <p>产品申请时间:{{item.gmtCreate|dataFormat}}</p>
  18. <p>产品申请机构名称:{{item.organizationName}}</p>
  19. <p>服务模式:<span v-for="acc in item.accessTypeArray" class="accType">{{acc}}</span></p>
  20. <p class="chooseService">选择建立的服务端:
  21. <span v-if="!!item.serviceInfos && item.serviceInfos.length != 0" :class="{'hide':item.isExpired || item.onlyOnline || item.serviceStatus ==0 || item.openedServiceStatus==0}">
  22. <el-radio v-for="i in item.serviceInfos" v-model="radio" :label="i.id+','+i.name+','+index">{{i.name}}</el-radio>
  23. </span>
  24. <!-- 产品未到开通时间 以及已过期 或被停用 或产品自身停用 或单独线上模式 都不显示! -->
  25. <!-- <span v-show="!item.isExpired && !item.unStarted && !item.onlyOnline && item.openedServiceStatus!=0 && item.serviceStatus !=0" class="btn addBtn" @click="addProductInfo">添加</span> -->
  26. <span v-show="!item.isExpired && !item.onlyOnline && item.openedServiceStatus!=0 && item.serviceStatus !=0" class="btn addBtn" @click="addProductInfo">添加</span>
  27. </p>
  28. <p class="tokenInfo">产品令牌</p>
  29. <p>用户请求接口时用户验证是否符合身份信息,请妥善保存</p>
  30. <!-- <div v-show="(new Date(item.endTime))>time && item.openedServiceStatus!=0 && item.serviceStatus !=0"> -->
  31. <!-- <div v-show="!item.isExpired && !item.unStarted && !item.onlyOnline && item.openedServiceStatus!=0 && item.serviceStatus !=0"> -->
  32. <div v-show="!item.isExpired && !item.onlyOnline && item.openedServiceStatus!=0 && item.serviceStatus !=0">
  33. <div v-if="item.selectFlag" class="btn blueBtn" @click="creatService(item.id,index)">点击生成</div>
  34. <div v-else class="btn createBtn">点击生成</div>
  35. </div>
  36. <img src="../../images/stop.png" height="54" width="54" class="overTime" v-if="item.openedServiceStatus==0 || item.serviceStatus ==0">
  37. <img src="../../images/overTime.png" height="54" width="54" class="overTime" v-else-if="item.isExpired">
  38. </div>
  39. <div v-show="noProduct" class="box">
  40. <h4>您尚未开通任何产品!</h4>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script type="text/javascript">
  46. import MiniTitle from '../common/MiniTile.vue'
  47. import api from '../../api/user.js'
  48. export default {
  49. name:'OpenedProduct',
  50. data(){
  51. return {
  52. product:[],
  53. noProduct:false,
  54. accType:{
  55. '1':'线上模式',
  56. '2':'接口方式',
  57. '3':'嵌入式',
  58. },
  59. radio:'',//对应服务id和name
  60. radioName:'',
  61. serviceData:[],
  62. flag:false,
  63. keyId:'',
  64. keySecret:'',
  65. // time:new Date(),
  66. }
  67. },
  68. created(){
  69. this.getProduct();
  70. },
  71. methods:{
  72. getProduct(){//获取已开通的产品
  73. const key = 'selectFlag';//服务端选中标识
  74. const value = false;
  75. const showKey = 'showKey';//令牌展示标识
  76. const keyValue = false;
  77. api.opendedProduct().then((res)=>{
  78. let result = res.data;
  79. if(+result.code == 0){
  80. let productData = result.data;
  81. if(productData.length != 0){
  82. for(var k in productData){
  83. productData[k][key] = value;
  84. productData[k][showKey] = keyValue;
  85. this.product.push(productData[k]);
  86. }
  87. } else{//没有开通产品
  88. this.noProduct = true;
  89. }
  90. }
  91. })
  92. },
  93. addProductInfo(){
  94. this.$router.push({path:'TJFWD'});//跳转到添加服务端
  95. },
  96. creatService(id,index){//点击生成
  97. this.radioName = this.radio.split(',')[1];
  98. const params = {
  99. 'productId':id,
  100. 'serviceId':this.radio.split(',')[0]
  101. }
  102. api.createServiceToken(params).then((res)=>{
  103. let result = res.data;
  104. if(+result.code == 0){//生成成功后直接跳转到已生成令牌详情 10-16-shenqiang
  105. const tokenMsg = result.data.serviceToken;
  106. const tokenId = tokenMsg.productServiceId;
  107. this.$router.push({path:'CKLPXQ',query:{id:tokenId}});
  108. }else{
  109. this.$message({
  110. message: result.msg,
  111. type: 'warning'
  112. });
  113. }
  114. })
  115. },
  116. copy(id){//点击复制
  117. let keyDom = document.getElementById(id);
  118. keyDom.select();
  119. document.execCommand("Copy");
  120. this.$message({
  121. message: '复制成功',
  122. type: 'success'
  123. });
  124. }
  125. },
  126. components:{
  127. MiniTitle
  128. },
  129. filters:{
  130. dataFormat(val){
  131. let time = val;
  132. let date = new Date(time);
  133. let year = date.getFullYear();
  134. let month = (date.getMonth()+1).toString().padStart(2,'0');
  135. let day = date.getDate().toString().padStart(2,'0');
  136. let hour = date.getHours().toString().padStart(2,'0');
  137. let minute = date.getMinutes().toString().padStart(2,'0');
  138. let times = year+'.'+month+'.'+day+' '+hour+':'+minute;
  139. return times;
  140. }
  141. },
  142. computed:{},
  143. watch:{//监听生成按钮
  144. radio:function(val){
  145. if(val){
  146. const index = this.radio.split(',')[2];
  147. for(let i in this.product){
  148. this.product[i].selectFlag = false
  149. }
  150. return this.product[index].selectFlag = true;
  151. }
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="less" scoped>
  157. @import '../../less/user.less';
  158. .opened{
  159. width: 100%;
  160. height: 95%;
  161. box-sizing: border-box;
  162. .base;
  163. .main-box{
  164. height:100%;
  165. overflow-y: scroll;
  166. }
  167. .btn{
  168. .button;
  169. .border;
  170. }
  171. .miniTit{
  172. .miniTitle;
  173. }
  174. .btnBox{
  175. margin-right: 20px;
  176. .lingpai{
  177. width: 90px;
  178. height:24px;
  179. line-height: 24px;
  180. margin-left: 10px;
  181. border-color: #1774f0;
  182. color: #1774f0;
  183. }
  184. }
  185. .box{
  186. position: relative;
  187. padding: 20px;
  188. margin: 20px;
  189. background: #fff;
  190. border-radius: 2px;
  191. min-width: 575px;
  192. h3{
  193. font-size: 14px;
  194. font-weight: bold;
  195. margin-bottom: 10px;
  196. }
  197. >p{
  198. margin-top: 24px;
  199. }
  200. .chooseService{
  201. line-height: 30px;
  202. margin-top: 19px;
  203. .el-radio__inner{
  204. border: 1px solid #9b9b9b!important;
  205. }
  206. }
  207. .overTime{
  208. position: absolute;
  209. top: 6px;
  210. right: 395px;
  211. }
  212. .accType{
  213. margin-right: 10px;
  214. }
  215. .expired{
  216. position: absolute;
  217. top: 20px;
  218. right: 20px;
  219. margin-top: 0;
  220. }
  221. .tokenInfo{
  222. margin-top: 30px;
  223. margin-bottom: -9px;
  224. }
  225. .addBtn{
  226. border-color: #1774f0;
  227. color: #1774f0;
  228. margin: -8px 0 0 15px;
  229. }
  230. .createBtn{
  231. color:#fff;
  232. background:#c9c9c9;
  233. margin-top: 34px;
  234. border: none;
  235. }
  236. .blueBtn{
  237. color:#fff;
  238. background:#1774f0;
  239. margin-top: 34px;
  240. border: none;
  241. }
  242. .copyBtn{
  243. border-color: #1774f0;
  244. color: #1774f0;
  245. margin-left: 30px;
  246. }
  247. .key{
  248. margin-top: 30px;
  249. padding-top: 25px;
  250. border-top: 1px dashed #c9c9c9;
  251. .keyText{
  252. width: 100%;
  253. input{
  254. height: 30px;
  255. width: 99%;
  256. margin-left: 15px;
  257. padding-left: 10px;
  258. }
  259. .tr{
  260. height:50px;
  261. }
  262. }
  263. .info{
  264. width: 10%;
  265. text-align: right;
  266. }
  267. .info1{
  268. width: 10%;
  269. text-align: left;
  270. }
  271. }
  272. .red{
  273. color:red;
  274. }
  275. .hide{
  276. display: none;
  277. }
  278. }
  279. }
  280. </style>