| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <template>
- <view class="warp">
- <uni-section title="商家列表" type="line">
- <uni-data-select v-model="shopId" :localdata="shopList" placeholder="请选择商家" @change="handleShopChange"
- class="padding" />
- </uni-section>
- <uni-section v-if="controlInfoList.length > 0" title="检查点列表" type="line">
- <uni-list>
- <uni-list-item v-for="item in controlInfoList" :key="item.ciid" showArrow :title="item.cicode"
- :clickable="true" @click="handleCiClick(item.ciid)" />
- <!-- <uni-list-item showArrow title="列表文字" rightText="右侧文字" /> -->
- </uni-list>
- </uni-section>
- </view>
- </template>
- <script>
- import {
- DefaultRequest,
- IdRequest
- } from "@/grpc/app_api_pb.js"
- // import { mobileUtils } from "@/utils/util.js"
- export default {
- components: {},
- data() {
- return {
- shopId: 0,
- shopList: [],
- controlInfoList: []
- }
- },
- computed: {},
- mounted() {},
- onLoad() {
- this.getShopList()
- },
- methods: {
- getShopList() {
- // 创建请求参数并赋值
- var request = new DefaultRequest()
- // 调用客户端相应的grpc方法,发送grpc请求,并接受后台发送回来的返回值
- this.$client.assShopList(request, {}, (err, response) => {
- if (err) {
- console.log(`[assShopList] err: code = ${err.code}` +
- `, message = "${err.message}"`)
- } else {
- // console.log(response)
- // let res = response.getListList()
- // let res = response.assShopListReply()
- // let res = this.$client.assShopListReply(response)
- // console.log(res)
- // console.log(res[0].toObject())
- let res = response.toObject().listList
- // console.log(res)
- let len = res.length
- this.shopList.length = 0 // 清空整个数组
- for (let i = 0; i < len; i++) {
- this.shopList[i] = {
- value: res[i].shopid,
- text: res[i].name,
- }
- }
- }
- });
- },
- getControlInfoList(shopId) {
- // 创建请求参数并赋值
- var request = new IdRequest()
- request.setId(shopId)
- // 调用客户端相应的grpc方法,发送grpc请求,并接受后台发送回来的返回值
- this.$client.assControlInfoList(request, {}, (err, response) => {
- if (err) {
- console.log(`[assControlInfoList] err: code = ${err.code}` +
- `, message = "${err.message}"`)
- } else {
- let res = response.toObject().listList
- // console.log(res)
- this.controlInfoList.length = 0 // 清空整个数组
- this.controlInfoList = res
- }
- })
- },
- handleShopChange(shopId) {
- console.log("shopId:" + shopId)
- this.getControlInfoList(shopId)
- },
- handleCiClick(ciId) {
- console.log("ciId:" + ciId)
- uni.navigateTo({
- // url: '/pages/checkPoint/checkPointDetail',
- url: './checkPointDetail?ciId=' + ciId
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .padding {
- padding: 0 20rpx;
- }
- </style>
|