position.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. top: 5%;
  86. left: 5%;
  87. }
  88. .position-tag.tr {
  89. top: 88rpx;
  90. right: 30rpx;
  91. top: 5%;
  92. left: 5%;
  93. text-align: right;
  94. }
  95. .position-tag.tc {
  96. top: 88rpx;
  97. top: 5%;
  98. left: 50%;
  99. transform: translate(-50%, 0);
  100. text-align: center;
  101. }
  102. .position-tag.cl {
  103. top: 50%;
  104. transform: translate(0, -50%);
  105. left: 30rpx;
  106. left: 5%;
  107. }
  108. .position-tag.cc {
  109. top: 50%;
  110. left: 50%;
  111. transform: translate(-50%, -50%);
  112. }
  113. .position-tag.cr {
  114. top: 50%;
  115. transform: translate(0, -50%);
  116. right: 30rpx;
  117. right: 5%;
  118. text-align: right;
  119. }
  120. .position-tag.bl {
  121. bottom: 125rpx;
  122. left: 30rpx;
  123. bottom: 10%;
  124. left: 5%;
  125. }
  126. .position-tag.br {
  127. bottom: 125rpx;
  128. bottom: 10%;
  129. right: 30rpx;
  130. text-align: right;
  131. }
  132. .position-tag.bc {
  133. bottom: 125rpx;
  134. bottom: 10%;
  135. left: 50%;
  136. transform: translate(-50%, 0);
  137. text-align: center;
  138. }
  139. .position-save {
  140. position: absolute;
  141. bottom: 30rpx;
  142. left: 135rpx;
  143. left: 30rpx;
  144. position: fixed;
  145. left: 30rpx;
  146. bottom: 30rpx;
  147. background: url(@/static/icon/position-save.png) no-repeat;
  148. background-size: 80rpx 80rpx;
  149. width: 80rpx;
  150. height: 80rpx;
  151. }
  152. </style>