position.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template name="dever-position">
  2. <view>
  3. <block v-for="(v, k) in item" :key="k">
  4. <view :class="['position-tag', position[v.text-1]]" v-if="v.name" @click="view(v.goods_id)">
  5. <view v-for="(v1, k1) in v.name_array" :key="k1">
  6. <text v-bind:style="{backgroundColor:(v.bgcolor || 'transparent'),color:v.color,fontSize:v.size+'px'}" v-if="v1">{{v1}}</text>
  7. </view>
  8. </view>
  9. </block>
  10. <view class="position-save" :data-url="down" @click="download" v-if="button == 1"></view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. button : {
  17. type : String,
  18. value : null
  19. },
  20. down : {
  21. type : String,
  22. value : null,
  23. },
  24. item : {
  25. type : Array,
  26. value : null
  27. },
  28. },
  29. data() {
  30. return {
  31. position: ["tl","tc","tr","cl","cc","cr","bl","bc","br"],
  32. };
  33. },
  34. methods:{
  35. download : function(e) {
  36. var url = e.target.dataset.url;
  37. var self = this;
  38. uni.downloadFile({
  39. url,
  40. success: res => {
  41. if (res.statusCode === 200) {
  42. console.info(res);
  43. uni.saveImageToPhotosAlbum({
  44. filePath: res.tempFilePath,
  45. success: function() {
  46. self.Dever.alert('保存成功');
  47. },
  48. fail: function() {
  49. self.Dever.alert('保存失败,请稍后重试');
  50. }
  51. });
  52. } else {
  53. self.Dever.alert('下载失败');
  54. }
  55. }
  56. });
  57. },
  58. view : function(id) {
  59. this.Dever.location('dream/product?id=' + id + '&table=&code=' + this.Dever.config.code);
  60. }
  61. },
  62. }
  63. </script>
  64. <style>
  65. .position-tag {
  66. position: fixed;
  67. color: #fff;
  68. display: flex;
  69. flex-direction: column;
  70. }
  71. .position-tag view{
  72. line-height: 1em;
  73. overflow: hidden;
  74. }
  75. .position-tag text {
  76. background-color: #000;
  77. margin-bottom: 10rpx;
  78. font-size: 28rpx;
  79. line-height: 1;
  80. padding: 0 2rpx;
  81. }
  82. .position-tag.tl {
  83. top: 88rpx;
  84. left: 30rpx;
  85. }
  86. .position-tag.tr {
  87. top: 88rpx;
  88. right: 30rpx;
  89. text-align: right;
  90. }
  91. .position-tag.tc {
  92. top: 88rpx;
  93. left: 50%;
  94. transform: translate(-50%, 0);
  95. text-align: center;
  96. }
  97. .position-tag.cl {
  98. top: 50%;
  99. transform: translate(0, -50%);
  100. left: 30rpx;
  101. }
  102. .position-tag.cc {
  103. top: 50%;
  104. left: 50%;
  105. transform: translate(-50%, -50%);
  106. }
  107. .position-tag.cr {
  108. top: 50%;
  109. transform: translate(0, -50%);
  110. right: 30rpx;
  111. text-align: right;
  112. }
  113. .position-tag.bl {
  114. bottom: 125rpx;
  115. left: 30rpx;
  116. }
  117. .position-tag.br {
  118. bottom: 125rpx;
  119. right: 30rpx;
  120. text-align: right;
  121. }
  122. .position-tag.bc {
  123. bottom: 125rpx;
  124. left: 50%;
  125. transform: translate(-50%, 0);
  126. text-align: center;
  127. }
  128. .position-save {
  129. position: absolute;
  130. bottom: 30rpx;
  131. left: 135rpx;
  132. left: 30rpx;
  133. position: fixed;
  134. left: 30rpx;
  135. bottom: 30rpx;
  136. background: url(@/static/icon/position-save.png) no-repeat;
  137. background-size: 80rpx 80rpx;
  138. width: 80rpx;
  139. height: 80rpx;
  140. }
  141. </style>