position.vue 2.8 KB

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