OrderPoster.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <tui-popup :duration="500" :mode-class="[ 'fade' ]" :styles="styles" :show="popupVisible">
  3. <view class="poster-container">
  4. <view style="max-height: 70vh;overflow-y: auto;">
  5. <image v-show="posterImage" class="poster-iamge" :src="posterImage" mode="widthFix" />
  6. <l-painter
  7. v-show="!posterImage" ref="painter" is-canvas-to-temp-file-path
  8. css=" background: #fff;border-radius: 32rpx;" @done="handlePainterSuccess"
  9. >
  10. <l-painter-view css="width: 600rpx;padding: 0 11rpx;">
  11. <l-painter-view css="width: 600rpx;textAlign: center;">
  12. <l-painter-text
  13. :text="headerTitle" css=" paddingTop: 16rpx;
  14. display: inline-block;
  15. color: #000;
  16. fontSize: 32rpx;
  17. fontWeight: bold;
  18. textAlign: center;"
  19. />
  20. </l-painter-view>
  21. <!-- <l-painter-text
  22. :text="topDesc" css=" display: block;
  23. color: #605D52;
  24. fontSize: 28rpx;
  25. marginTop: 12rpx;
  26. marginBottom: 14rpx;
  27. line-clamp: 4;
  28. "
  29. ></l-painter-text> -->
  30. </l-painter-view>
  31. <l-painter-view css="margin: 32rpx;width: 602rpx;">
  32. <l-painter-view v-for="(brand, i) in brandList" :key="i">
  33. <l-painter-view css="marginTop: 10rpx;marginBottom: 10rpx;">
  34. <l-painter-image
  35. :src="require('../../static/images/user/mendianshenqing.png')" :css="{
  36. background: logoBg,
  37. objectFit: 'contain',
  38. width: '38rpx'
  39. }"
  40. />
  41. <l-painter-text :text="brand.brandName" css="marginLeft: 10rpx;color: #000000;fontSize: 32rpx;line-clamp: 1;"></l-painter-text>
  42. </l-painter-view>
  43. <l-painter-view
  44. v-for="(item, index) in brand.goodsList" :key="index"
  45. css="display: flex;align-items: center;width: 538rpx;marginBottom: 18rpx;"
  46. >
  47. <l-painter-image
  48. :src="common.seamingImgUrl(item.picUrl)" :css="{
  49. background: logoBg,
  50. objectFit: 'contain',
  51. width: '208rpx'
  52. }"
  53. />
  54. <l-painter-view css="flex: 1;marginLeft: 20rpx;marginTop: 10rpx;">
  55. <l-painter-text
  56. :text="item.goodsName"
  57. css="display: block;color: #605D52;fontSize: 28rpx;line-clamp: 3;"
  58. ></l-painter-text>
  59. <l-painter-text
  60. :text="item.specifications"
  61. css="display: block;color: #605D52;fontSize: 24rpx;"
  62. ></l-painter-text>
  63. <l-painter-view css="marginTop: 10rpx;">
  64. <l-painter-text text="¥" css="color: #ff0000;fontSize: 26rpx;"></l-painter-text>
  65. <l-painter-text :text="item.price" css="color: #ff0000;fontSize: 28rpx;"></l-painter-text>
  66. </l-painter-view>
  67. </l-painter-view>
  68. </l-painter-view>
  69. </l-painter-view>
  70. </l-painter-view>
  71. <!-- :src="require('../../static/images/icon/line.png')" -->
  72. <!-- <l-painter-view
  73. css="padding: 10rpx;
  74. display: flex;
  75. justifyContent: flex-start;
  76. width: 602rpx;"
  77. >
  78. <l-painter-view css="width: 350rpx;textAlign: center;">
  79. <l-painter-image
  80. :src="logo" :css="{
  81. background: logoBg,
  82. objectFit: 'contain',
  83. width: '158rpx',
  84. height: '158rpx'
  85. }"
  86. />
  87. <l-painter-text
  88. text="下单享优惠,分享得福利!" css=" display: block;
  89. color: #605D52;
  90. fontSize: 22rpx;
  91. marginTop: 20rpx"
  92. ></l-painter-text>
  93. </l-painter-view>
  94. <l-painter-view css="width: 170rpx;textAlign: center;marginLeft: 28rpx">
  95. <l-painter-image
  96. :src="shareCode" css="width: 158rpx;
  97. height: 158rpx"
  98. ></l-painter-image>
  99. <l-painter-text
  100. text="赶快行动吧!!" css=" display: block;
  101. color: #605D52;
  102. fontSize: 22rpx;
  103. marginTop: 20rpx"
  104. ></l-painter-text>
  105. </l-painter-view>
  106. </l-painter-view> -->
  107. </l-painter>
  108. </view>
  109. <view style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
  110. <button class="uni-btn" @click="handleSaveImage">
  111. <!-- #ifdef H5 -->
  112. <text>提示:可长按或截屏进行保存</text>
  113. <!-- #endif -->
  114. <!-- #ifdef APP || MP -->
  115. <text>保存</text>
  116. <!-- #endif -->
  117. </button>
  118. <view class="close-wrapper">
  119. <tui-icon name="close" color="#fff" :size="37" @click="handleClosePopup"></tui-icon>
  120. </view>
  121. </view>
  122. </view>
  123. <!-- 分析logo颜色 -->
  124. <canvas id="tui-color-palette" class="canvas-el" canvas-id="tui-color-palette"></canvas>
  125. <tui-toast ref="toast"></tui-toast>
  126. </tui-popup>
  127. </template>
  128. <script>
  129. import { saveImg } from '../../utils'
  130. export default {
  131. name: 'OrderPoster',
  132. data() {
  133. return {
  134. styles: Object.freeze({
  135. 'position': 'fixed',
  136. 'bottom': 0,
  137. 'top': 0,
  138. 'left': 0,
  139. 'right': 0,
  140. 'z-index': 997,
  141. 'display': 'flex',
  142. 'justify-content': 'center',
  143. 'align-items': 'flex-start',
  144. 'padding-top': '7vh',
  145. 'background': 'rgba(0, 0, 0, 0.6)'
  146. }),
  147. posterImage: '',
  148. logoBg: '#fff',
  149. popupVisible: false,
  150. brandList: [],
  151. shareCode: null,
  152. headerTitle: ''
  153. }
  154. },
  155. methods: {
  156. show({ headerTitle, brandList }) {
  157. this.posterImage = ''
  158. this.headerTitle = headerTitle
  159. this.brandList = brandList
  160. // this.topDesc = topDesc
  161. // this.logo = logo
  162. this.popupVisible = true
  163. this.$forceUpdate()
  164. },
  165. handleSaveImage() {
  166. // // #ifdef H5
  167. // uni.showToast({
  168. // title: '长按二维码即可分享和保存活动邀请码',
  169. // duration: 2000,
  170. // icon: 'none'
  171. // })
  172. // // #endif
  173. // // #ifdef APP || MP
  174. // uni.saveFile({
  175. // tempFilePath: this.posterImage,
  176. // success:(res)=> {
  177. // var savedFilePath = res.savedFilePath
  178. // this.ttoast({
  179. // title: '活动邀请码保存成功'
  180. // })
  181. // }
  182. // })
  183. // // #endif
  184. if (this.posterImage) {
  185. saveImg(this.posterImage)
  186. } else {
  187. this.$refs.painter.canvasToTempFilePathSync({
  188. // 在nvue里是jpeg
  189. fileType: 'jpg',
  190. pathType: 'url',
  191. quality: 1,
  192. success: (res) => {
  193. saveImg(res.tempFilePath)
  194. }
  195. })
  196. }
  197. },
  198. // 绘制活动邀请码成功
  199. handlePainterSuccess() {
  200. this.$nextTick(() => {
  201. this.$refs.painter.canvasToTempFilePathSync({
  202. fileType: 'jpg',
  203. pathType: 'url',
  204. quality: 1,
  205. success: (res) => {
  206. if (!this.posterImage) {
  207. this.posterImage = res.tempFilePath
  208. // console.log(this.posterImage)
  209. }
  210. }
  211. })
  212. })
  213. },
  214. handleClosePopup() {
  215. this.popupVisible = false
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="less" scoped>
  221. .poster-container {
  222. width: 622upx;
  223. text-align: center;
  224. border-radius: 32upx;
  225. box-sizing: border-box;
  226. .uni-btn {
  227. width: 80%;
  228. height: 60upx;
  229. font-size: 28upx;
  230. line-height: 60upx;
  231. border-radius: 100px;
  232. background-color: #fff;
  233. margin: 16upx 0;
  234. }
  235. .poster-iamge {
  236. width: 622upx;
  237. border-radius: 32upx;
  238. }
  239. }
  240. .canvas-el {
  241. position: absolute;
  242. z-index: -1;
  243. }
  244. </style>