application.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" :title="modeName"></u-navbar>
  5. <view class="content">
  6. <view class="search">
  7. <u-search :animation="true" searchIcon="search" placeholder="输入设备名称" v-model="keyword"
  8. :showAction="false" @search="search"></u-search>
  9. </view>
  10. <view class="list" v-if="deviceList&&deviceList.length>0">
  11. <view class="thumb-box" v-for="(item, index) in deviceList" :key="item.deviceId"
  12. @click.stop="commItemSelect(item)">
  13. <view>
  14. <image class="select-img"
  15. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/selected.png"
  16. mode="widthFix" v-show="item.checked"></image>
  17. <image class="select-img"
  18. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/select.png"
  19. mode="widthFix" v-show="!item.checked"></image>
  20. </view>
  21. <view class="check-content">
  22. <!-- <view class="comm-img">
  23. <u--image width="130rpx" height="130rpx" :src="item.cover" mode="widthFix"
  24. :lazy-load="true"></u--image>
  25. </view> -->
  26. <view class="comm-main">
  27. <view>
  28. {{item.deviceName}}
  29. </view>
  30. <view>
  31. 状态:{{item.deviceStateLName}}
  32. </view>
  33. <view>
  34. 状态:{{item.deviceStateLName}}
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <u-loadmore :status="status" v-if="deviceList.length>=1" />
  40. </view>
  41. <view class="empty" v-else>
  42. <u-empty></u-empty>
  43. </view>
  44. </view>
  45. <view class='btn safe-bottom'>
  46. <xbutton size='large' width='100%' @tap='applyToDevice'>确定应用到设备</xbutton>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. searchPage
  53. } from '@/api/device/device.js'
  54. import {
  55. saveGoodsDevice,
  56. } from "@/api/commoditylist/commoditylist.js"
  57. export default {
  58. data() {
  59. return {
  60. keyword: '',
  61. deviceList: [],
  62. page: 1,
  63. size: 10,
  64. modelId:null,
  65. modeName:null
  66. }
  67. },
  68. onLoad(o) {
  69. if (o.modelId) {
  70. this.modelId=modelId
  71. this.modeName=modeName
  72. }
  73. },
  74. onShow() {
  75. this.getList()
  76. },
  77. methods: {
  78. search(val) {
  79. this.reset()
  80. this.getList()
  81. },
  82. // 商品选中状态改变
  83. commItemSelect(e) {
  84. e.checked = !e.checked;
  85. },
  86. reset() {
  87. this.status == 'loadmore'
  88. this.page = 1;
  89. this.deviceList = [];
  90. },
  91. getList() {
  92. searchPage({
  93. page: {
  94. current: this.page,
  95. size: this.size
  96. },
  97. keywords: this.keyword,
  98. }).then(res => {
  99. let data = res.data.records;
  100. for (let i = 0; i < data.length; i++) {
  101. let item = data[i];
  102. item.checked = false;
  103. }
  104. if (data.length < 10) {
  105. this.status = "nomore"
  106. } else {
  107. this.status = "loadmore"
  108. }
  109. this.deviceList = this.deviceList.concat(data)
  110. })
  111. },
  112. onReachBottom() {
  113. if (this.status == 'nomore') return
  114. this.page++
  115. this.getList()
  116. },
  117. applyToDevice() {
  118. saveGoodsDevice({
  119. "deviceIds": [], //设备信息id
  120. "mercId": 0, //商户ID
  121. "modelId": 0 //商品清单ID
  122. }).then(res => {})
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .container {
  129. .content {
  130. padding-bottom: 88rpx;
  131. .search {
  132. padding: 24rpx 24rpx;
  133. background-color: #fff;
  134. }
  135. .list {
  136. width: 100%;
  137. padding: 12rpx 24rpx;
  138. .thumb-box {
  139. margin-bottom: 12rpx;
  140. border-bottom: 1rpx solid #f4f4f4;
  141. display: flex;
  142. flex-flow: row nowrap;
  143. padding: 12rpx 12rpx;
  144. align-items: center;
  145. background-color: #fff;
  146. border-radius: 12rpx;
  147. }
  148. .select-img {
  149. width: 40rpx;
  150. height: 40rpx;
  151. }
  152. .check-content {
  153. width: 100%;
  154. display: flex;
  155. flex-direction: row;
  156. align-items: center;
  157. padding-left: 12rpx;
  158. position: relative;
  159. .comm-img {
  160. width: 130rpx;
  161. height: 130rpx;
  162. display: flex;
  163. flex-direction: row;
  164. align-items: center;
  165. justify-content: space-around;
  166. image {
  167. width: 100%;
  168. }
  169. }
  170. .comm-main {
  171. box-sizing: border-box;
  172. padding-left: 18rpx;
  173. color: #999;
  174. >view {
  175. padding: 8rpx 0;
  176. width: 330rpx;
  177. font-size: 28rpx;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. .empty {
  184. position: absolute;
  185. left: 50%;
  186. top: 50%;
  187. transform: translate(-50%, -50%);
  188. }
  189. .btn {
  190. width: 724rpx;
  191. position: fixed;
  192. left: 13rpx;
  193. bottom: calc(24rpx + env(safe-area-inset-bottom) / 2);
  194. border-radius: 88rpx;
  195. overflow: hidden;
  196. }
  197. }
  198. </style>