share.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. define({
  2. name:"share",
  3. template:`
  4. <div class="share">
  5. <el-form>
  6. <div class="vue-main-title">
  7. <div class="vue-main-title-left"></div>
  8. <div class="vue-main-title-content">分享关注</div>
  9. </div>
  10. <div style="margin:0 auto;width:80%;">
  11. <el-form-item label="分享标题">
  12. <el-input style="width:500px;" v-model="json.share_title" ></el-input>
  13. <p>如果不填写,默认为商品名称</p>
  14. </el-form-item>
  15. <el-form-item label="分享图标">
  16. <div class="upload-boxed" @click="displayUploadImagePopup('goods_image')">
  17. <div v-if="json.share_thumb && json.share_thumb != ' '">
  18. <img :src="json.share_thumb" alt="" style="width: 150px; height: 150px; border-radius: 5px; cursor: pointer;">
  19. </div>
  20. <div v-else>
  21. <div class="el-icon-plus" style="font-size: 60px;cursor: pointer;"></div>
  22. <div class="upload-boxed-text">点击上传图片</div>
  23. </div>
  24. </div>
  25. <p style="margin-left: 70px;">如果不选择,默认为商品缩略图片</p>
  26. </el-form-item>
  27. <el-form-item label="分享描述">
  28. <el-input style="width:500px;" v-model="json.share_desc" ></el-input>
  29. <p>如果不填写,默认为商品名称</p>
  30. </el-form-item>
  31. </div>
  32. </el-form>
  33. <upload-multimedia-img
  34. :upload-show="showUploadImagePopup"
  35. :type="type" :name="chooseImgName"
  36. selNum="one"
  37. @replace="displayUploadImagePopup"
  38. @sure="selectedImage"
  39. ></upload-multimedia-img>
  40. </div>
  41. `,
  42. style:`
  43. `,
  44. props: {
  45. form: {
  46. default() {
  47. return {}
  48. }
  49. }
  50. },
  51. data() {
  52. return {
  53. showUploadImagePopup: false,
  54. chooseImgName: "",
  55. type:"",
  56. json: {
  57. share_title: '',
  58. share_thumb: '',
  59. share_desc: '',
  60. }
  61. }
  62. },
  63. mounted() {
  64. if(this.form && JSON.stringify(this.form) !== '[]') {
  65. this.json.share_title = this.form.share_title;
  66. this.json.share_thumb = this.form.share_thumb;
  67. this.json.share_desc = this.form.share_desc;
  68. }
  69. },
  70. methods:{
  71. displayUploadImagePopup(type = "goods_image") {
  72. this.type = "1";
  73. this.chooseImageName = type;
  74. this.showUploadImagePopup = !this.showUploadImagePopup;
  75. },
  76. selectedImage(name, show, images) {
  77. this.json.share_thumb = images[0]["url"];
  78. this.$forceUpdate()
  79. },
  80. extraDate(){
  81. },
  82. validate(){
  83. return this.json;
  84. }
  85. }
  86. })