test.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view style="height: 100%;width: 100%;">
  3. <!-- <view style="width: 100%;">
  4. <image style="width: 100%;" mode="widthFix" :src="$util.spliceAssetsUrl('/om/home-header.png')"></image>
  5. </view> -->
  6. <!-- <span style="color: #FFFFFF;">{{ tableData.length }}</span> -->
  7. <view v-if="tableData.length == 0">
  8. <view style="height: 100%;width: 100%;" @click="onchange('/upms/views/home/home?type=' + 1)">
  9. <u-empty text="暂无活动" :icon="$util.spliceAssetsUrl('/ma/empty_data.png')" :iconSize="100" width="300"
  10. height="300" marginTop="700" textSize="56">
  11. </u-empty>
  12. </view>
  13. </view>
  14. <swiper class="screen-swiper round-dot" :indicator-dots="false" :circular="true" :autoplay="false"
  15. interval="5000" duration="500" v-else>
  16. <block v-for="(item,index) in tableData" :key="index">
  17. <swiper-item @click="onchange('/upms/views/home/home?type=' + 1)"
  18. class="flex justify-center align-center" v-if="item.activityType == 0">
  19. <!-- <u--image :src="item.fileUrl" mode="aspectFill" v-if="item.activityType == 0"
  20. :errorIcon="$util.spliceAssetsUrl('/ma/empty_data.png')" bgColor="#1F262C"></u--image> -->
  21. <!-- <video :src="item.fileUrl" :autoplay="true" :loop="true" v-if="item.activityType == 1" :show-fullscreen-btn="false"></video> -->
  22. <!-- <image :src="item.fileUrl" mode="aspectFill"> -->
  23. <!-- <view class="text-white">{{ item.isError }}</view> -->
  24. <image :src="item.fileUrl" mode="aspectFill" v-if="!item.isError" @error="errorImage(index)" />
  25. <u-empty text="活动图片加载失败" :icon="$util.spliceAssetsUrl('/ma/empty_data.png')" :iconSize="100"
  26. width="300" height="300" marginTop="100" textSize="56" v-else>
  27. </u-empty>
  28. </swiper-item>
  29. </block>
  30. </swiper>
  31. <!-- 测试打印机模板 -->
  32. <!-- <view class="m-t-20">
  33. <button class="cu-btn round bg-gradual-blue shadow" @click="testPrintString">测试打印机模板</button>
  34. </view>
  35. <view class="m-t-20">
  36. <button class="cu-btn round bg-gradual-blue shadow" @click="onchange('/upms/views/dineWay/dineWay')">下一页</button>
  37. </view> -->
  38. </view>
  39. </template>
  40. <script>
  41. import api from '@/utils/api'
  42. const app = getApp();
  43. export default {
  44. data() {
  45. return {
  46. cardCur: "",
  47. theme: app.globalData.theme, //全局颜色变量
  48. keySecret: "",
  49. errorImagenumber: 0,
  50. tableData: []
  51. }
  52. },
  53. mounted() {
  54. this.getList()
  55. if (this.tableData.length == 0) {
  56. //如果没有活动,需要直接跳入点餐界面
  57. this.onchange('/upms/views/home/home?type=' + 1)
  58. }
  59. },
  60. methods: {
  61. getList() {
  62. api.orderingMachineActivityList().then(res => {
  63. this.tableData = res.data
  64. for (var i = 0; i < this.tableData.length; i++) {
  65. this.tableData[i].isError = false
  66. this.$set(this.tableData, i, this.tableData[i])
  67. this.$forceUpdate()
  68. }
  69. })
  70. },
  71. errorImage(e) {
  72. this.tableData[e].isError = true
  73. // this.$set(this.tableData, e, this.tableData[e])
  74. console.log(this.tableData[e].isError)
  75. },
  76. cardSwiper(e) {
  77. this.cardCur = e.detail.current
  78. },
  79. onchange(url) {
  80. uni.navigateTo({
  81. url: url
  82. })
  83. },
  84. // 测试打印机模板
  85. testPrintString() {
  86. api.takeAwayMachineTemplate('1590535772905246721').then(res => {
  87. let tplStr = res.data
  88. const ToastPlusModule = uni.requireNativePlugin("unitest")
  89. ToastPlusModule.androidPrint(tplStr, pRes => {
  90. uni.showToast({
  91. title: "打印状态--->" + pRes,
  92. icon: 'none',
  93. duration: 2000
  94. });
  95. })
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. .tower-swiper .tower-item {
  103. transform: scale(calc(0.5 + var(--index) / 10));
  104. margin-left: calc(var(--left) * 100upx - 150upx);
  105. z-index: var(--index);
  106. }
  107. .screen-swiper {
  108. // min-height: 600rpx;
  109. // margin-left: 80rpx;
  110. // margin-right: 80rpx;
  111. // margin-top: 20rpx;
  112. height: 1920px;
  113. width: 100%;
  114. }
  115. .uni-swiper-dots {
  116. display: NONE;
  117. align-items: center;
  118. width: 100%;
  119. justify-content: center;
  120. }
  121. </style>