Browse Source

feat(zhaomu-item): 添加订阅模板消息功能并优化代码格式

- 在toZhaomu方法中新增订阅消息功能
- 优化代码缩进和格式
- 调整条件渲染逻辑的代码结构
master
前端-胡立永 2 days ago
parent
commit
112f257761
1 changed files with 67 additions and 34 deletions
  1. +67
    -34
      components/zhaomu/zhaomu-item.vue

+ 67
- 34
components/zhaomu/zhaomu-item.vue View File

@ -26,27 +26,23 @@
<!-- <uv-avatar-group :urls="urls" keyName="headImage" size="45rpx" gap="0.1"></uv-avatar-group>
<view class="num">{{item.num}}人参加</view> -->
</view>
<view class="bottom-box-r"
v-if="!item.openState"
@click="toZhaomu(item)">
<view class="bottom-box-r" v-if="!item.openState" @click="toZhaomu(item)">
{{$t('components.zhaomu.zhaomuItem.joinRecruit')}}
</view>
<view class="bottom-box-r"
v-else-if="item.openState == 3"
@click="toZhaomu(item)">
<view class="bottom-box-r" v-else-if="item.openState == 3" @click="toZhaomu(item)">
{{$t('components.zhaomu.zhaomuItem.rejected')}}
</view>
<view class="bottom-box-r"
v-else
>
<view class="bottom-box-r" v-else>
{{ [$t('components.zhaomu.zhaomuItem.reviewing'), $t('components.zhaomu.zhaomuItem.joined')][item.openState - 1] }}
</view>
</view>
<view class="tabs-box" :class="item == 1? 'bzcx-item' : 'ycx-item'">
{{item == 1? $t('components.zhaomu.zhaomuItem.guaranteed') : $t('components.zhaomu.zhaomuItem.confirmed')}}
</view>
<view class="tabs-box" :class="item == 1? 'bzcx-item' : 'ycx-item'">{{item == 1? $t('components.zhaomu.zhaomuItem.guaranteed') : $t('components.zhaomu.zhaomuItem.confirmed')}}</view>
</view>
</view>
</template>
@ -56,13 +52,13 @@
props: {
item: {
type: Object,
default: ()=>{}
default: () => {}
},
},
data() {
return {
iconTextArr:[],
imgArr:[],
iconTextArr: [],
imgArr: [],
urls: [
'https://cdn.uviewui.com/uview/album/1.jpg',
'https://cdn.uviewui.com/uview/album/2.jpg',
@ -70,19 +66,46 @@
]
};
},
watch:{
item:{
handler(val){
watch: {
item: {
handler(val) {
this.iconTextArr = val.iconText ? val.iconText.split(",") : [];
this.imgArr = val.image ? val.image.split(",") : []
this.urls = val.popularizeRecruitLogList;
},
immediate:true
immediate: true
}
},
mounted() {
},
mounted() {},
methods: {
//
onSubscribeMessageTap(fn) {
let templateIds = [
'SQd2axWZD7KCw3jkw--tumMz9-cmP_R2FUhJzByxrP8',
];
wx.requestSubscribeMessage({
tmplIds: templateIds, // ID
success(res) {
fn && fn(res)
console.log('订阅消息调用成功', res);
// res[tmplId] ID
// res['your_template_id_1'] === 'accept'
templateIds.forEach(tmplId => {
if (res[tmplId] === 'accept') {
console.log(`用户同意订阅模板ID:${tmplId}`);
//
} else if (res[tmplId] === 'reject') {
console.log(`用户拒绝订阅模板ID:${tmplId}`);
} else {
console.log(`用户对该模板ID的订阅请求:${res[tmplId]}`); // 'ban'
}
});
},
fail(err) {
console.error('订阅消息调用失败', err);
}
});
},
skip(val) {
uni.navigateTo({
url: '/pages_order/orderDetails'
@ -90,13 +113,15 @@
},
toZhaomu(item) {
let params = {
recruitId:item.id,
recruitId: item.id,
}
this.$api('shopUserAuth',params,res=>{
this.$emit('getData')
if(res.code == 200) {
this.$Toast(this.$t('components.zhaomu.zhaomuItem.joinSuccess'))
}
this.onSubscribeMessageTap(res => {
this.$api('shopUserAuth', params, res => {
this.$emit('getData')
if (res.code == 200) {
this.$Toast(this.$t('components.zhaomu.zhaomuItem.joinSuccess'))
}
})
})
}
}
@ -159,17 +184,19 @@
.address {
display: flex;
margin-bottom: 10rpx;
.img-box {
width: 22rpx;
height: 26rpx;
margin-right: 10rpx;
flex-shrink: 0;
image {
width: 100%;
height: 100%;
}
}
}
}
@ -177,6 +204,7 @@
display: flex;
align-items: center;
flex-wrap: wrap;
.tips-box-item {
padding: 0 24rpx;
height: 38rpx;
@ -187,12 +215,13 @@
color: #999999;
margin-right: 14rpx;
margin-bottom: 5px;
&:last-child {
margin-right: 0;
}
}
}
}
}
@ -203,9 +232,11 @@
justify-content: space-between;
height: 104rpx;
padding: 0 21rpx;
&-l {
display: flex;
align-items: center;
.num {
font-weight: 500;
font-size: 25rpx;
@ -213,6 +244,7 @@
margin-left: 20rpx;
}
}
&-r {
width: 180rpx;
height: 53rpx;
@ -225,7 +257,7 @@
line-height: 53rpx;
}
}
.tabs-box {
position: absolute;
top: 0;
@ -237,11 +269,13 @@
text-align: center;
line-height: 40rpx;
}
.bzcx-item {
background: url('@/static/image/member/bzcx-bg.png') no-repeat;
background-size: 100% 100%;
color: #FF9000;
}
.ycx-item {
background: url('@/static/image/member/ycx-bg.png') no-repeat;
background-size: 100% 100%;
@ -249,5 +283,4 @@
}
}
}
</style>

Loading…
Cancel
Save