Bladeren bron

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

lifanagju_citu 4 maanden geleden
bovenliggende
commit
f427d7bdc5

+ 9 - 1
src/api/mall/prize.js

@@ -35,7 +35,15 @@ export const luckyLotteryRecordReceive = async (data) => {
 // 根据商品id活动对应的奖品区域信息
 export const getPrizeAreaByGoodsId = async (params) => {
   return await request.get({
-		url: 'app-api/promotion/luck-prize/get/extend/area',
+		url: '/app-api/promotion/luck-prize/get/extend/area',
+		params
+	})
+}
+
+// 抽奖记录分页
+export const getLuckLotteryRecordPage = async (params) => {
+  return await request.get({
+		url: '/app-api/promotion/luck-lottery-record/page',
 		params
 	})
 }

+ 6 - 2
src/views/mall/components/prizeDraw.vue

@@ -22,8 +22,8 @@
         {{ prizeData?.prompt }}
         <div class="mt-5 font-weight-bold color-primary text-decoration-underline cursor-pointer" @click="emit('success')">点击前往“我的-我的奖品”中领取</div>
         <!-- <div class="my-10">
-          <v-btn color="primary" variant="outlined" width="120">取 消</v-btn>
-          <v-btn color="primary" width="120" class="ml-5" @click.stop="handleReceive">领 取</v-btn>
+          <v-btn color="primary" variant="outlined" width="120" @click="showDialog = false">取 消</v-btn>
+          <v-btn color="primary" width="120" class="ml-5" @click.stop="handleReceive">前往领取</v-btn>
         </div> -->
       </div>
     </CtDialog>
@@ -120,6 +120,10 @@ const endCallback  = (value) => {
   showDialog.value = true
   getLuckyNum()
 }
+
+const handleReceive = () => {
+  showDialog.value = false
+}
 </script>
 
 <style scoped lang="scss">

+ 1 - 1
src/views/mall/payOver/index.vue

@@ -2,7 +2,7 @@
 <template>
   <Navbar class="mb-3" />
   <v-card class="default-width my-3">
-    <showText class="mb-7"></showText>
+    <showText :class="{'mb-15': !showPrizeDraw}"></showText>
 
     <!-- 抽奖 -->
     <prizeDraw v-if="showPrizeDraw" :lotteryId="lotteryId" class="prizeDraw mx-15 mb-7" @success="handleReceive"></prizeDraw>

+ 32 - 38
src/views/mall/user/prize/index.vue

@@ -6,6 +6,7 @@
     :loading="false"
     :elevation="0"
     :isTools="false"
+    :total="total"
     :showPage="true"
     :showSelect="false"
 		:page-info="queryParams"
@@ -21,10 +22,10 @@
       {{ item.record.deliverInfo ? JSON.parse(item.record.deliverInfo).name + '-' + JSON.parse(item.record.deliverInfo).no  : ''}}
     </template>
     <template #receiveInfo="{ item }">
-      {{ item.record.receiveInfo ? JSON.parse(item.record.receiveInfo).name + ',' + JSON.parse(item.record.receiveInfo).phone + ',' + JSON.parse(item.record.receiveInfo).address : ''}}
+      {{ orderReceiveInfo(item) }}
     </template>
     <template #actions="{ item }">
-      <v-btn v-if="item.record.isReceive && !item.record.receiveInfo" color="primary" @click.stop="handleSelectAddress(item)" variant="text">选择收货地址</v-btn>
+      <v-btn v-if="!item.record.isReceive && !item.record.receiveInfo" color="primary" @click.stop="handleReceive(item)" variant="text">领取</v-btn>
     </template>
   </CtTable>
 
@@ -37,46 +38,17 @@
 
 <script setup>
 defineOptions({ name: 'mall-user-prize-index' })
-import { ref } from 'vue'
+import { ref, computed } from 'vue'
 import SelectAddress from '@/views/mall/user/address'
 import Snackbar from '@/plugins/snackbar'
+import { getLuckLotteryRecordPage, luckyLotteryRecordReceive } from '@/api/mall/prize'
 
 const queryParams = ref({
 	pageNo: 1,
 	pageSize: 10,
 })
-const items = ref([
-	{
-		record: {
-      createTime: 1735128516469,
-      isReceive: true,
-      deliverInfo: "{\"no\":\"SF112056000216589\",\"name\":\"顺丰速运\"}",
-      receiveInfo: '{"name":"张三","phone":"13800138000","address":"北京市海淀区上地十街10号百度大厦"}',
-    },
-    prize: {
-      name: '三亚酒店房券',
-      image: 'https://menduner.citupro.com:3443/dev/e13f9b76b26907f35d0ccf7e7f3e88f89a725429172e0b56ceb88362bc9032e6.jpg'
-    },
-    lottery: {
-      name: '房券抽奖活动'
-    }
-	},
-  {
-		record: {
-      createTime: 1735128516469,
-      isReceive: true,
-      deliverInfo: '',
-      receiveInfo: ''
-    },
-    prize: {
-      name: '三亚酒店房券',
-      image: 'https://menduner.citupro.com:3443/dev/e13f9b76b26907f35d0ccf7e7f3e88f89a725429172e0b56ceb88362bc9032e6.jpg'
-    },
-    lottery: {
-      name: '房券抽奖活动'
-    }
-	}
-])
+const total = ref(0)
+const items = ref([])
 
 const headers = [
   { title: '活动名称', key: 'lottery.name', sortable: false },
@@ -87,17 +59,39 @@ const headers = [
   { title: '操作', key: 'actions', sortable: false }
 ]
 
-// 设置收货地址
+// 获取中奖记录
+const getLuckLotteryRecordList = async () => {
+  const result = await getLuckLotteryRecordPage(queryParams.value)
+  items.value = result?.list || []
+  total.value = result?.total || 0
+}
+getLuckLotteryRecordList()
+
+// 收货信息
+const orderReceiveInfo = computed(() => (item) => {
+  const info = item.record.receiveInfo ? JSON.parse(item.record.receiveInfo) : {}
+  if (!info || !Object.keys(info).length) return ''
+  return `${info.name},${info.mobile},${info.areaName} ${info.detailAddress}`
+})
+
+// 领取
 const selectAddressRef = ref()
 const showDialog = ref(false)
-const handleSelectAddress = () => {
+const recordId = ref('')
+const handleReceive = (item) => {
+  recordId.value = item.record.id
   showDialog.value = true
 }
 
 const handleSubmit = async () => {
   const receive = selectAddressRef.value.getSelected() || {}
   if (!receive || !Object.keys(receive).length) return Snackbar.warning('请选择您的收货地址')
-  console.log(receive, '收货地址')
+  // console.log(receive, '收货地址', recordId.value)
+  await luckyLotteryRecordReceive({ id: recordId.value, receiveInfo: JSON.stringify(receive) })
+  showDialog.value = false
+  recordId.value = null
+  Snackbar.success('领取成功,待商家发货')
+  getLuckLotteryRecordList()
 }
 </script>