deviceManage.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="设备管理"></u-navbar>
  5. <view class="content">
  6. <view class="search">
  7. <u-search animation placeholder="搜索设备" :clearabled="false" v-model="keyword" :showAction="false"
  8. @search="search"></u-search>
  9. <view class="scan-icon" @click="scan">
  10. <u-icon name="scan" size="22" color="#909399"></u-icon>
  11. </view>
  12. </view>
  13. <view class="tab-wrap">
  14. <view class="tab">
  15. <u-tabs :list="tabList" :activeStyle="{color: '#333',fontWeight: 'bold',fontSize:'36rpx'}"
  16. :inactiveStyle="{fontSize:'32rpx'}" :scrollable="false" :current="current" @click="tabClick"
  17. lineColor="#2C6FF3">
  18. </u-tabs>
  19. </view>
  20. </view>
  21. <scroll-view class="scrollview" :scroll-with-animation="true" scroll-y lower-threshold="100"
  22. @scrolltolower="scrolltolower" :style="{height:fullHeight}">
  23. <view class="list" v-if="list&&list.length>0">
  24. <block v-for="(item, index) in list" :key="index">
  25. <view class="thumb-box" @click="detail(item)">
  26. <!-- <view>
  27. <image class="select-img"
  28. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/no_selected.png"
  29. mode="widthFix" v-show="item.noSelect"></image>
  30. <image class="select-img"
  31. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/selected.png"
  32. mode="widthFix" v-show="!item.noSelect&&item.checked"></image>
  33. <image class="select-img"
  34. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/select.png"
  35. mode="widthFix" v-show="!item.noSelect&&!item.checked"></image>
  36. </view> -->
  37. <view class="check-content">
  38. <!-- <view class="comm-img">
  39. <u--image width="130rpx" height="130rpx" :src="item.cover" mode="widthFix"
  40. :lazy-lord="true"></u--image>
  41. </view> -->
  42. <view class="comm-main">
  43. <view>
  44. {{item.deviceName||'/'}}
  45. </view>
  46. <view v-if="item.activeState==2">
  47. 商户前缀:{{item.mercPrefix}}
  48. <!-- <text class="under-line-text" @click.stop="copy(item.mercPrefix)">复制</text> -->
  49. </view>
  50. <view>
  51. 设备id:{{item.deviceId}}
  52. <!-- <text class="under-line-text"
  53. @click.stop="copy(item.deviceId)">复制</text> -->
  54. </view>
  55. <view>
  56. 设备sn:{{item.deviceSn}}
  57. <!-- <text class="under-line-text"
  58. @click.stop="copy(item.deviceSn)">复制</text> -->
  59. </view>
  60. <view v-if="item.activeState==1">
  61. 激活时间:{{item.activeTime}}
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </block>
  67. <view class="more" style="overflow: hidden;">
  68. <u-loadmore :status="status" v-if="list.length>=1" />
  69. </view>
  70. </view>
  71. <view class="empty" v-if="list.length==0">
  72. <u-empty mode="list" text="没有设备!"></u-empty>
  73. </view>
  74. </scroll-view>
  75. </view>
  76. <!--<view class="btn">
  77. <xbutton size="large" @click="submit">{{btnName}}({{selectList.length}})</xbutton>
  78. </view> -->
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. aliDeviceActivePage
  84. } from "@/api/device/device.js"
  85. export default {
  86. data() {
  87. return {
  88. page: 1, //商品分页
  89. size: 10,
  90. status: 'loadmore', //加载更多
  91. tabList: [{
  92. name: '未激活'
  93. },
  94. {
  95. name: '已激活'
  96. }
  97. ],
  98. current: 0,
  99. fullHeight: 0,
  100. list: []
  101. }
  102. },
  103. computed: {
  104. activeState() {
  105. let val = 1;
  106. if (this.current == 0) {
  107. val = 2
  108. } else {
  109. val = 1
  110. }
  111. return val
  112. }
  113. },
  114. onLoad(o) {
  115. let _this = this;
  116. const query = uni.createSelectorQuery().in(this);
  117. query.select(".scrollview").boundingClientRect((data) => {
  118. uni.getSystemInfo({
  119. success(res) {
  120. // 针对iPhone X等机型底部安全距离做适配
  121. const model = res.model;
  122. const modelInclude = [
  123. "iPhone X",
  124. 'iPhone XR',
  125. "iPhone XS",
  126. "iPhone XS MAX",
  127. "iPhone 12/13 mini",
  128. "iPhone 12/13 (Pro)",
  129. "iPhone 12/13 Pro Max",
  130. "iPhone 14 Pro Max"
  131. ];
  132. let safeDistance = modelInclude.includes(model)
  133. //动态设置商品区域高度
  134. if (safeDistance) {
  135. _this.fullHeight = res.windowHeight - data.top - 34 + 'px';
  136. } else {
  137. _this.fullHeight = res.windowHeight - data.top + 'px';
  138. }
  139. },
  140. });
  141. }).exec();
  142. this.getList()
  143. },
  144. methods: {
  145. search(val) {
  146. this.reset();
  147. this.getList()
  148. },
  149. tabClick(e) {
  150. console.log(e.index)
  151. this.current = e.index
  152. this.search()
  153. },
  154. //扫码
  155. scan() {
  156. uni.scanCode({
  157. success: (res) => {
  158. this.keyword = res.result;
  159. this.getList()
  160. }
  161. });
  162. },
  163. //根据类目获取商品列表
  164. getList(id) {
  165. aliDeviceActivePage({
  166. page: {
  167. current: this.page,
  168. size: this.size
  169. },
  170. activeState: this.activeState
  171. }).then(res => {
  172. let newData = res.data.records;
  173. if (newData.length < 10) {
  174. this.status = "nomore"
  175. } else {
  176. this.status = "loadmore"
  177. }
  178. this.list = this.list.concat(newData)
  179. })
  180. },
  181. //触底加载更多
  182. scrolltolower() {
  183. if (this.status == 'nomore') return
  184. this.page++
  185. this.getList()
  186. },
  187. reset() {
  188. this.status == 'loadmore'
  189. this.page = 1;
  190. this.size = 10;
  191. this.list = [];
  192. },
  193. copy(text) {
  194. uni.setClipboardData({
  195. data: toString(text),
  196. success: (data) => {
  197. uni.showToast({
  198. title: '复制成功'
  199. })
  200. },
  201. fail: function(err) {
  202. console.log(err)
  203. },
  204. complete: function(res) {
  205. console.log(res)
  206. }
  207. })
  208. },
  209. submit() {
  210. },
  211. detail(item){
  212. this.$tab.navigateTo(`/pages/activeDevice/bindAliDev?id=${item.deviceId}`)
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .container {
  219. .content {
  220. .search {
  221. padding: 24rpx 24rpx 12rpx;
  222. background-color: #fff;
  223. position: relative;
  224. .scan-icon {
  225. position: absolute;
  226. right: 36rpx;
  227. top: 38rpx;
  228. z-index: 2;
  229. }
  230. .search-history {
  231. .history-item {
  232. margin-right: 24rpx;
  233. padding: 0 12rpx;
  234. background-color: #f2f2f2;
  235. color: #333;
  236. font-size: 24rpx;
  237. line-height: 40rpx;
  238. border-radius: 40rpx;
  239. margin-top: 24rpx;
  240. }
  241. }
  242. }
  243. .tab-wrap {
  244. background-color: #fff;
  245. .tab{
  246. width:50%;
  247. }
  248. }
  249. .list {
  250. width: 100%;
  251. padding: 0rpx 13rpx 12rpx;
  252. padding-bottom: calc(110rpx + env(safe-area-inset-bottom) / 2);
  253. overflow: hidden;
  254. .thumb-box {
  255. border-bottom: 1rpx solid #f4f4f4;
  256. display: flex;
  257. flex-flow: row nowrap;
  258. padding: 20rpx 30rpx;
  259. align-items: center;
  260. background-color: #fff;
  261. border-radius: 12rpx;
  262. margin-top: 12rpx;
  263. }
  264. .select-img {
  265. width: 40rpx;
  266. height: 40rpx;
  267. }
  268. .check-content {
  269. display: flex;
  270. flex-direction: row;
  271. align-items: center;
  272. .comm-img {
  273. width: 130rpx;
  274. height: 130rpx;
  275. display: flex;
  276. flex-direction: row;
  277. align-items: center;
  278. justify-content: space-around;
  279. image {
  280. width: 100%;
  281. }
  282. }
  283. .comm-main {
  284. box-sizing: border-box;
  285. color: #333;
  286. font-size: 28rpx;
  287. .under-line-text {
  288. font-size: 26rpx !important;
  289. font-weight: 500;
  290. font-style: italic;
  291. text-decoration: underline;
  292. color: #2C6FF3 !important;
  293. margin-left: 24rpx;
  294. background-color: #fff !important;
  295. }
  296. >view {
  297. padding: 4rpx 0;
  298. line-height: 50rpx;
  299. }
  300. >view:nth-child(1) {
  301. font-size: 30rpx;
  302. font-weight: bold;
  303. color: #333;
  304. }
  305. >view:nth-child(2) {
  306. // font-size: 28rpx;
  307. }
  308. >view:nth-child(3) {
  309. // font-size: 28rpx;
  310. }
  311. >view:nth-child(4) {
  312. // font-size: 28rpx;
  313. text {
  314. font-weight: bold;
  315. color: red;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. }
  322. .btn {
  323. width: 100%;
  324. position: fixed;
  325. left: 0;
  326. padding: 0 24rpx;
  327. }
  328. .empty {
  329. position: absolute;
  330. left: 50%;
  331. top: 50%;
  332. transform: translate(-50%, -50%);
  333. }
  334. }
  335. </style>