12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- var PreviewPanel = {
- template: '<div class="preview-wrap">\
- <p class="c-t-center c-bold">{{modelName}}</p>\
- <div v-html="content" class="mtb10 c-333"></div>\
- <div v-for="(url,i) in imgs" class="mtb10"><img :src="url" width="100%" /></div>\
- <div class="foot-btns">\
- <a class="back-btn c-t-center mr15" @click="goBack">\
- 返回\
- </a>\
- </div>\
- </div>',
- props: [],
- data: function() {
- return {
- content: "",
- modelName:"",
- createTime: "",
- imgs: []
- }
- },
- // beforeRouteEnter: function (to, from, next) {
- // next(function(vm) {
- // var query = vm.$route.query
- // if(query && query.modelCode) {
- // vm.modelCode = query.modelCode
- // vm.listDetail()
- // }
- // })
- // },
- created: function() {
- var vm = this
- EventBus.$on('preview-template', function(data) {
- var regN = /\n/g;
- vm.content = data.content.replace(regN,"<br/>").replace(/ /g, " ");
- vm.modelName = data.modelName
- vm.imgs = data.imgs
- })
- },
- methods: {
- listDetail: function() {
- var vm = this
- guidanceAPI.listDetail({
- modelCode: vm.modelCode
- }).then(function(res) {
- var data = res.data
- if(data) {
- var regN = /\n/g;
- vm.content = data.content.replace(regN,"<br/>").replace(/ /g, " ");
- vm.modelName = data.modelName
- vm.createTime = data.createTime
- vm.imgs = _.map(data.imagesUrls, function(s) {
- return httpRequest.getImgUrl(s)
- })
- }
- })
- },
- getDetail: function (){
- var regN = /\n/g;
- var regRN = /\r\n/g;
- var content = detail.content.replace(/ /g, " ");
- content = content.replace(regN,"<br/>");
- var p = "<p class='c-f14 c-333'>"+content+"</p>",
- images = "";
- for(i=0; i<detail.images.length; i++){
- var src = detail.images[i];
- if(!(src.indexOf("file://") > -1)){
- src = getImgUrl(detail.images[i]);
- }
-
- images += "<div class='mtb10'><img src='"+src+"' width='100%'></div>";
- }
- $(".content").append(p+images);
- },
- goBack: function() {
- this.$router.back()
- }
- }
- }
|