Browse Source

feat: 签到接口对接;

pull/6/head
fox 2 weeks ago
parent
commit
44b7b3ec99
5 changed files with 86 additions and 37 deletions
  1. +2
    -2
      pages/index/center.vue
  2. +6
    -7
      pages_order/mine/pointsRecord.vue
  3. +71
    -26
      pages_order/mine/signIn.vue
  4. +5
    -2
      pages_order/order/createOrder.vue
  5. +2
    -0
      store/store.js

+ 2
- 2
pages/index/center.vue View File

@ -72,7 +72,7 @@
</view>
<view class="flex flex-column">
<!-- todo: 字段对接 -->
<view class="account-value">{{ riceInfo.balance || 0 }}</view>
<view class="account-value">{{ userCenterData.score || 0 }}</view>
<view class="account-label">我的积分</view>
</view>
<view class="flex flex-column">
@ -168,7 +168,7 @@
},
computed: {
...mapGetters(['role']),
...mapState(['userInfo', 'vipInfo', 'riceInfo']),
...mapState(['userInfo', 'userCenterData', 'vipInfo', 'riceInfo']),
isMerchants() {
return this.userInfo.isMerchants === '1'
},


+ 6
- 7
pages_order/mine/pointsRecord.vue View File

@ -6,7 +6,7 @@
<view class="tools">
<uv-datetime-picker
ref="datetimePicker"
v-model="queryParams.selectedTime"
v-model="queryParams.createTime"
mode="year-month"
confirmColor="#84A73F"
@confirm="onTimeChange"
@ -40,6 +40,8 @@
</template>
<script>
import dayjs from 'dayjs'
import mixinsList from "@/mixins/list.js"
export default {
mixins: [mixinsList],
@ -48,14 +50,14 @@
queryParams: {
pageNo: 1,
pageSize: 10,
selectedTime: new Date(),
createTime: dayjs().format('YYYY-MM'),
},
mixinsListApi: 'queryScoreList',
}
},
computed: {
displaySelectedTime() {
return this.$dayjs(this.queryParams.selectedTime).format("YYYY年M月")
return this.$dayjs(this.queryParams.createTime).format("YYYY年M月")
}
},
methods: {
@ -63,10 +65,7 @@
this.$refs.datetimePicker.open();
},
onTimeChange(e) {
this.queryParams.selectedTime = e.value
this.queryParams.pageNo = 1
this.queryParams.pageSize = 10
this.queryParams.createTime = this.$dayjs(e.value).format('YYYY-MM')
this.getData()
},
}


+ 71
- 26
pages_order/mine/signIn.vue View File

@ -10,15 +10,15 @@
<!-- todo: 对接接口 -->
<view class="flex info">
<view class="flex flex-column info-item">
<view class="info-value">5</view>
<view class="info-value">{{ duration }}</view>
<view class="info-label">连续签到/</view>
</view>
<view class="flex flex-column info-item">
<view class="info-value">20</view>
<view class="info-value">{{ total }}</view>
<view class="info-label">累计签到/</view>
</view>
<view class="flex flex-column info-item">
<view class="info-value">50</view>
<view class="info-value">{{ userCenterData.score }}</view>
<view class="info-label">获得积分</view>
</view>
</view>
@ -51,46 +51,91 @@
</template>
<script>
import { mapState } from 'vuex'
export default {
data() {
return {
// todo: fetch
signedDates: [],
// signedDates: SELECTED_DATE_ARR.map(date => {
// return {
// date,
// info: date[date.length - 1],
// infoColor: '#FFFFFF',
// badge: true,
// }
// }),
isSigned: false
total: 0,
duration: 0,
isSigned: false,
}
},
onLoad() {
if (uni.getStorageSync('token')) {
this.$store.commit('getUserCenterInfo')
this.fetchSignedData()
}
},
computed: {
...mapState(['userCenterData']),
},
methods: {
async fetchSignedData() {
try {
const res = await this.$fetch('queryScoreList')
const { records, total } = res
const today = this.$dayjs()
let todaySigned = false
let duration = 0
let baseDay = today.subtract(1, 'day')
const set = new Set()
const dates = []
records.forEach(item => {
const { createTime } = item
const date = this.$dayjs(createTime)
const dateStr = date.format("YYYY-MM-DD")
if (set.has(dateStr)) {
return
}
set.add(dateStr)
if (!todaySigned && date.isSame(today, 'day')) {
todaySigned = true
}
if (date.isSame(baseDay, 'day')) {
duration++
baseDay = baseDay.subtract(1, 'day')
}
dates.push({
date: date.format("YYYY-MM-DD"),
info: date.date(),
infoColor: '#FFFFFF',
badge: true,
})
})
this.signedDates = dates
this.isSigned = todaySigned
this.isSigned && (duration++)
this.duration = duration
this.total = total
} catch (err) {
}
},
async onSignIn() {
try {
await this.$fetch('sign')
this.isSigned = true
const date = this.$dayjs()
this.signedDates.push({
date: date.format("YYYY-MM-DD"),
info: date.date(),
infoColor: '#FFFFFF',
badge: true,
})
this.$store.commit('getUserCenterInfo')
this.fetchSignedData()
uni.showToast({
title: '签到成功~',
});
// todo: refresh overview data
} catch (err) {
}


+ 5
- 2
pages_order/order/createOrder.vue View File

@ -107,9 +107,12 @@
...mapState(['userInfo', 'payOrderProduct']),
},
onLoad({ id }) {
this.$store.commit('getUserInfo')
this.$store.commit('getUserCenterInfo')
this.orderId = id
if(uni.getStorageSync('token')) {
this.$store.commit('getUserInfo')
this.$store.commit('getUserCenterInfo')
}
},
onShow() {
this.getCouponList()


+ 2
- 0
store/store.js View File

@ -16,6 +16,7 @@ const store = new Vuex.Store({
state: {
configList: {}, //配置列表
userInfo: {}, //用户信息
userCenterData: {},
vipInfo: {},
riceInfo: {}, //用户相关信息
payOrderProduct: [], //支付订单中的商品
@ -132,6 +133,7 @@ const store = new Vuex.Store({
api('getUserCenterData', res => {
if (res.code == 200) {
Vue.set(state, 'vipInfo', res.result?.vipInfo || {})
Vue.set(state.userCenterData, 'score', res.result?.score || 0)
}
})
},


Loading…
Cancel
Save