Commit 73a21cbe authored by Facius's avatar Facius

feat: 收费项接口调试

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