Commit 73a21cbe authored by Facius's avatar Facius

feat: 收费项接口调试

parent 005fb4fc
Pipeline #3670 canceled with stages
......@@ -129,4 +129,24 @@ export async function repairSign(data) {
data,
noLoading: true
})
}
// 获取用户服务项列表
export async function getRepairServiceTemplate(data) {
return request({
url: `/rest/repair/getRepairServiceTemplate`,
method: 'GET',
data,
noLoading: true
})
}
// 收藏-取消收藏服务项
export async function dealCollect(data) {
return request({
url: `/rest/repair/dealCollect/${data.id}`,
method: 'GET',
data,
noLoading: true
})
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
<NavbarRight title="收费项" />
<view class="tabs-view">
<u-tabs height="62" activeColor="#02A074" inactive-color="#333333" bg-color="#F6F7FA" bar-height="4"
bar-width="40" :bar-style="{ 'background-color': '#02A074' }" :list="tabs" :page="current" @change="change"
bar-width="40" :bar-style="{ 'background-color': '#02A074' }" :list="tabs" :current="current" @change="change"
font-size="32" bold></u-tabs>
</view>
<view class="title-view">
......@@ -16,7 +16,7 @@
refresher-background="#F6F7FA" @refresherrefresh="onRefresh" @refresherrestore="onRestore" enable-back-to-top>
<view class="list-view" v-if="charges && charges.length > 0">
<view v-for="(item, index) in charges" :key="index" class="item-view">
<CellCharge :info="item" @select="handleSelect" @collect="handleCollect" />
<CellCharge :info="item" @select="handleSelect" @collectFlag="handleCollect" />
</view>
<view class="load-more-view" v-show="(page == 1 && !loading) || page > 1">
<u-loadmore :status="loadStatus" bgColor="#F6F7FA"></u-loadmore>
......@@ -36,8 +36,8 @@
import NavbarRight from '@/components/navbar-right';
import CellCharge from './components/cell-charge';
import NoData from '@/components/no-data';
import { getChargeList, updateCharge } from '@/api/project/index.js';
import { mapGetters } from 'vuex';
import { getRepairServiceTemplate, dealCollect } from '@/api/maintain/index.js';
export default {
components: {
......@@ -58,6 +58,7 @@ export default {
};
},
computed: {
...mapGetters(['chargeIndex']),
baseUrl () {
return process.uniEnv.qn_base_url;
},
......@@ -77,74 +78,52 @@ export default {
},
onLoad (options) {
this.freshing = false;
this.current = this.chargeIndex
this.reloadList();
},
methods: {
reloadList () {
this.page = 1;
this.loadStatus = 'loading';
this.getChargeList();
this.getRepairServiceTemplate();
},
getChargeList () {
getRepairServiceTemplate () {
if (this.page == 1) {
this.loading = true;
}
// getChargeList({
// page: this.page,
// collect: this.current,
// size: this.size,
// })
// .then(res => {
var res = {
data: {
records: [
{
id: '1',
name: '服务',
collect: true,
unit: '米',
},
{
id: '2',
name: '线缆',
collect: false,
unit: '米',
},
{
id: '3',
name: '螺丝',
collect: true,
unit: '个',
getRepairServiceTemplate({
page: this.page,
collectFlag: this.current == 0 ? false : true,
size: this.size,
})
.then(res => {
let data = res.data;
if (this.page == 1) {
this.charges = [];
}
if (data) {
this.charges.push(...data);
this.loadStatus = data.total > this.charges.length ? 'loadmore' : 'nomore';
} else {
this.loadStatus = 'nomore'
}
this.$nextTick(() => {
if (this.freshing) {
this.triggered = false;
this.freshing = false;
}
]
}
}
let data = res.data;
if (this.page == 1) {
this.charges = [];
}
if (data.records) {
this.charges.push(...data.records);
this.loadStatus = data.total > this.charges.length ? 'loadmore' : 'nomore';
} else {
this.loadStatus = 'nomore'
}
this.$nextTick(() => {
if (this.freshing) {
this.triggered = false;
this.freshing = false;
}
});
this.loading = false;
})
.catch(err => {
this.loading = false;
console.log(err);
});
this.loading = false;
// })
// .catch(err => {
// this.loading = false;
// console.log(err);
// });
},
change () {
change (index) {
this.current = index
this.reloadList()
this.$store.dispatch('Save_charge_index', index);
},
onRefresh () {
......@@ -160,16 +139,18 @@ export default {
if (this.loadStatus != 'loadmore') return;
this.page += 1;
this.loadStatus == 'loading';
this.getChargeList();
this.getRepairServiceTemplate();
},
handleCollect (id, collect) {
handleCollect (id, collectFlag) {
for (var item of this.charges) {
if (item.id == id) {
item.collect = collect
// this.updateCharge(id)
item.collectFlag = collectFlag
this.dealCollect({
collectFlag: collectFlag,
id:id})
this.$refs.uToast.show({
title: collect ? '收藏成功' : '取消成功',
title: collectFlag ? '收藏成功' : '取消成功',
type: 'success',
duration: 1500,
callback: () => {
......@@ -179,10 +160,8 @@ export default {
}
}
},
updateCharge (id) {
updateCharge({
id: id
})
dealCollect (params) {
dealCollect(params)
.then(res => {
let data = res.data;
if (data) {
......@@ -190,8 +169,8 @@ export default {
})
.catch(err => {
for (var item of this.employees) {
if (item.id == id) {
item.collect = !item.collect
if (item.id == params.id) {
item.collectFlag = !item.collectFlag
break
}
}
......
<template>
<view class="cell-charge" @click="$u.throttle(handleClickCell, 500)">
<view class="left-view">{{ info.name }}</view>
<view class="left-view">{{ info.serviceName }}</view>
<view class="right-view">
<view class="unit-view">{{info.unit}}</view>
<view class="collect-view" @click.stop="$u.throttle(handleSelect, 500)" hover-class="u-hover-class">
<image :src="collectImage" class="collect-image"></image>
<view class="collectFlag-view" @click.stop="$u.throttle(handleSelect, 500)" hover-class="u-hover-class">
<image :src="collectImage" class="collectFlag-image"></image>
</view>
</view>
</view>
......@@ -18,8 +18,8 @@ export default {
default () {
return {
id: '',
name: '',
collect: '',
serviceName: '',
collectFlag: '',
unit: '',
}
},
......@@ -33,14 +33,14 @@ export default {
return process.uniEnv.qn_base_url
},
collectImage () {
return this.baseUrl + (this.info.collect ? 'dianjishoucang1@3x.png' : 'shoucangshoufei0@3x.png')
return this.baseUrl + (this.info.collectFlag ? 'dianjishoucang1@3x.png' : 'shoucangshoufei0@3x.png')
},
},
created () { },
methods: {
handleSelect () {
this.info.collect = !this.info.collect
this.$emit('collect', this.info.id, this.info.collect)
this.info.collectFlag = !this.info.collectFlag
this.$emit('collectFlag', this.info.id, this.info.collectFlag)
},
handleClickCell () {
this.$emit('select', { ...this.info })
......@@ -75,7 +75,7 @@ export default {
.unit-view {}
.collect-view {
.collectFlag-view {
margin-left: 56rpx;
width: 80rpx;
height: 80rpx;
......@@ -83,7 +83,7 @@ export default {
justify-content: center;
align-items: center;
.collect-image {
.collectFlag-image {
width: 32rpx;
height: 32rpx;
}
......
......@@ -171,7 +171,7 @@ export default {
uni.$on('charge-selected', res => {
var form = JSON.parse(res || {})
this.form.unit = form.unit
this.form.name = form.name
this.form.name = form.serviceName
});
},
destroyed() {
......
......@@ -13,5 +13,6 @@ const getters = {
customId:state=>state.bill.customId,
canGetLocation:state=>state.map.canGetLocation,
prevProjectId:state=>state.workpoint.prevProjectId,
chargeIndex:state=>state.bill.chargeIndex,
}
export default getters
......@@ -5,12 +5,16 @@ import {
setCustomId,
getCustomId,
removeCustomId,
setChargeIndex,
getChargeIndex,
removeChargeIndex,
} from "@/utils/common.js"
const state = {
billType: getBillType()||'INCOME',
customId:getCustomId()||null,
chargeIndex:getChargeIndex()||0,
}
const mutations = {
......@@ -30,6 +34,14 @@ const mutations = {
state.customId = null
removeCustomId()
},
SAVE__CHARGE_INDEX: (state, data) => {
state.chargeIndex = data
setChargeIndex(data)
},
REMOVE_CHARGE_INDEX: (state, data) => {
state.chargeIndex = null
removeChargeIndex()
},
}
const actions = {
......@@ -57,6 +69,18 @@ const actions = {
}) => {
commit("REMOVE_CUSTOM_ID")
},
Save_charge_index:({
state,
commit
},data) => {
commit("SAVE__CHARGE_INDEX", data)
},
Remove_charge_index:({
state,
commit
}) => {
commit("REMOVE_CHARGE_INDEX")
},
}
export default {
......
......@@ -154,6 +154,18 @@ export function removeProjectId() {
uni.removeStorageSync("PROJECT-ID")
}
export function setChargeIndex(data) {
uni.setStorageSync("CHARGE-INDEX", data);
}
export function getChargeIndex() {
return uni.getStorageSync("CHARGE-INDEX") || 0
}
export function removeChargeIndex() {
uni.removeStorageSync("CHARGE-INDEX")
}
export function checkLoginAndVip(callback) {
if (checkToken()) {
if (checkVip()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment