123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- <template>
- <view class="container">
- <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
- :placeholder="true" title="设备管理"></u-navbar>
- <view class="content">
- <view class="search">
- <u-search animation placeholder="搜索设备" :clearabled="false" v-model="keyword" :showAction="false"
- @search="search"></u-search>
- <view class="scan-icon" @click="scan">
- <u-icon name="scan" size="22" color="#909399"></u-icon>
- </view>
- </view>
- <view class="tab-wrap">
- <view class="tab">
- <u-tabs :list="tabList" :activeStyle="{color: '#333',fontWeight: 'bold',fontSize:'36rpx'}"
- :inactiveStyle="{fontSize:'32rpx'}" :scrollable="false" :current="current" @click="tabClick"
- lineColor="#2C6FF3">
- </u-tabs>
-
- </view>
- </view>
- <scroll-view class="scrollview" :scroll-with-animation="true" scroll-y lower-threshold="100"
- @scrolltolower="scrolltolower" :style="{height:fullHeight}">
- <view class="list" v-if="list&&list.length>0">
- <block v-for="(item, index) in list" :key="index">
- <view class="thumb-box" @click="detail(item)">
- <!-- <view>
- <image class="select-img"
- src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/no_selected.png"
- mode="widthFix" v-show="item.noSelect"></image>
- <image class="select-img"
- src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/selected.png"
- mode="widthFix" v-show="!item.noSelect&&item.checked"></image>
- <image class="select-img"
- src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/commodity/select.png"
- mode="widthFix" v-show="!item.noSelect&&!item.checked"></image>
- </view> -->
- <view class="check-content">
- <!-- <view class="comm-img">
- <u--image width="130rpx" height="130rpx" :src="item.cover" mode="widthFix"
- :lazy-lord="true"></u--image>
- </view> -->
- <view class="comm-main">
- <view>
- {{item.deviceName||'/'}}
- </view>
- <view v-if="item.activeState==2">
- 商户前缀:{{item.mercPrefix}}
- <!-- <text class="under-line-text" @click.stop="copy(item.mercPrefix)">复制</text> -->
- </view>
- <view>
- 设备id:{{item.deviceId}}
- <!-- <text class="under-line-text"
- @click.stop="copy(item.deviceId)">复制</text> -->
- </view>
- <view>
- 设备sn:{{item.deviceSn}}
- <!-- <text class="under-line-text"
- @click.stop="copy(item.deviceSn)">复制</text> -->
- </view>
- <view v-if="item.activeState==1">
- 激活时间:{{item.activeTime}}
- </view>
- </view>
- </view>
- </view>
- </block>
- <view class="more" style="overflow: hidden;">
- <u-loadmore :status="status" v-if="list.length>=1" />
- </view>
- </view>
- <view class="empty" v-if="list.length==0">
- <u-empty mode="list" text="没有设备!"></u-empty>
- </view>
- </scroll-view>
- </view>
- <!--<view class="btn">
- <xbutton size="large" @click="submit">{{btnName}}({{selectList.length}})</xbutton>
- </view> -->
- </view>
- </template>
- <script>
- import {
- aliDeviceActivePage
- } from "@/api/device/device.js"
- export default {
- data() {
- return {
- page: 1, //商品分页
- size: 10,
- status: 'loadmore', //加载更多
- tabList: [{
- name: '未激活'
- },
- {
- name: '已激活'
- }
- ],
- current: 0,
- fullHeight: 0,
- list: []
- }
- },
- computed: {
- activeState() {
- let val = 1;
- if (this.current == 0) {
- val = 2
- } else {
- val = 1
- }
- return val
- }
- },
- onLoad(o) {
- let _this = this;
- const query = uni.createSelectorQuery().in(this);
- query.select(".scrollview").boundingClientRect((data) => {
- uni.getSystemInfo({
- success(res) {
- // 针对iPhone X等机型底部安全距离做适配
- const model = res.model;
- const modelInclude = [
- "iPhone X",
- 'iPhone XR',
- "iPhone XS",
- "iPhone XS MAX",
- "iPhone 12/13 mini",
- "iPhone 12/13 (Pro)",
- "iPhone 12/13 Pro Max",
- "iPhone 14 Pro Max"
- ];
- let safeDistance = modelInclude.includes(model)
- //动态设置商品区域高度
- if (safeDistance) {
- _this.fullHeight = res.windowHeight - data.top - 34 + 'px';
- } else {
- _this.fullHeight = res.windowHeight - data.top + 'px';
- }
- },
- });
- }).exec();
- this.getList()
- },
- methods: {
- search(val) {
- this.reset();
- this.getList()
- },
- tabClick(e) {
- console.log(e.index)
- this.current = e.index
- this.search()
- },
- //扫码
- scan() {
- uni.scanCode({
- success: (res) => {
- this.keyword = res.result;
- this.getList()
- }
- });
- },
- //根据类目获取商品列表
- getList(id) {
- aliDeviceActivePage({
- page: {
- current: this.page,
- size: this.size
- },
- activeState: this.activeState
- }).then(res => {
- let newData = res.data.records;
- if (newData.length < 10) {
- this.status = "nomore"
- } else {
- this.status = "loadmore"
- }
- this.list = this.list.concat(newData)
- })
- },
- //触底加载更多
- scrolltolower() {
- if (this.status == 'nomore') return
- this.page++
- this.getList()
- },
- reset() {
- this.status == 'loadmore'
- this.page = 1;
- this.size = 10;
- this.list = [];
- },
- copy(text) {
- uni.setClipboardData({
- data: toString(text),
- success: (data) => {
- uni.showToast({
- title: '复制成功'
- })
- },
- fail: function(err) {
- console.log(err)
- },
- complete: function(res) {
- console.log(res)
- }
- })
- },
- submit() {
- },
-
- detail(item){
- this.$tab.navigateTo(`/pages/activeDevice/bindAliDev?id=${item.deviceId}`)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- .content {
- .search {
- padding: 24rpx 24rpx 12rpx;
- background-color: #fff;
- position: relative;
- .scan-icon {
- position: absolute;
- right: 36rpx;
- top: 38rpx;
- z-index: 2;
- }
- .search-history {
- .history-item {
- margin-right: 24rpx;
- padding: 0 12rpx;
- background-color: #f2f2f2;
- color: #333;
- font-size: 24rpx;
- line-height: 40rpx;
- border-radius: 40rpx;
- margin-top: 24rpx;
- }
- }
- }
- .tab-wrap {
- background-color: #fff;
- .tab{
- width:50%;
- }
- }
- .list {
- width: 100%;
- padding: 0rpx 13rpx 12rpx;
- padding-bottom: calc(110rpx + env(safe-area-inset-bottom) / 2);
- overflow: hidden;
- .thumb-box {
- border-bottom: 1rpx solid #f4f4f4;
- display: flex;
- flex-flow: row nowrap;
- padding: 20rpx 30rpx;
- align-items: center;
- background-color: #fff;
- border-radius: 12rpx;
- margin-top: 12rpx;
- }
- .select-img {
- width: 40rpx;
- height: 40rpx;
- }
- .check-content {
- display: flex;
- flex-direction: row;
- align-items: center;
- .comm-img {
- width: 130rpx;
- height: 130rpx;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-around;
- image {
- width: 100%;
- }
- }
- .comm-main {
- box-sizing: border-box;
- color: #333;
- font-size: 28rpx;
- .under-line-text {
- font-size: 26rpx !important;
- font-weight: 500;
- font-style: italic;
- text-decoration: underline;
- color: #2C6FF3 !important;
- margin-left: 24rpx;
- background-color: #fff !important;
- }
- >view {
- padding: 4rpx 0;
- line-height: 50rpx;
- }
- >view:nth-child(1) {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- >view:nth-child(2) {
- // font-size: 28rpx;
- }
- >view:nth-child(3) {
- // font-size: 28rpx;
- }
- >view:nth-child(4) {
- // font-size: 28rpx;
- text {
- font-weight: bold;
- color: red;
- }
- }
- }
- }
- }
- }
- .btn {
- width: 100%;
- position: fixed;
- left: 0;
- padding: 0 24rpx;
- }
- .empty {
- position: absolute;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- }
- }
- </style>
|