index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <!--
  3. @copyright CYZ
  4. @time 2022/8/5
  5. 捐赠消息(首页、公益专区等页面)
  6. -->
  7. <view class="main">
  8. <view class="list">
  9. <view class="item" v-for="(item, index) in listData" :key="index" @click="item.type == 0?goDonation(item):goBuy(item)">
  10. <template v-if="item.msg_body.welfare_type != null">
  11. <!-- 公益捐赠(捐款) -->
  12. <image v-if="item.type == 0 && item.msg_body.model_type == 2 && item.msg_body.welfare_type == 0" mode="aspectFill" class="cover-2" src="/static/common/msg-type1.png"></image>
  13. <!-- 公益捐赠(捐物) -->
  14. <image v-else-if="item.type == 0 && item.msg_body.model_type == 2 && item.msg_body.welfare_type == 1" mode="aspectFill" class="cover-2" src="/static/common/msg-type3.png"></image>
  15. <!-- 官方捐赠 -->
  16. <image v-else-if="item.type == 0 && item.msg_body.model_type == 0" mode="aspectFill" class="cover-2" src="/static/common/msg-type1.png"></image>
  17. <!-- 积分捐赠 -->
  18. <image v-else-if="item.type == 0 && item.msg_body.model_type == 1" mode="aspectFill" class="cover-2" src="/static/common/msg-type2.png"></image>
  19. </template>
  20. <image v-else-if="item.type == 1" mode="aspectFill" class="cover" :src="item.msg_body.goods_cover"></image>
  21. <view class="right-2" v-if="item.type == 0">
  22. <view class="title">{{item.content}}</view>
  23. <view class="buy-box">
  24. <view class="desc">绿马爱心公益助残基金</view>
  25. <button @click="goDonation(item)">去捐赠</button>
  26. </view>
  27. </view>
  28. <view class="right" v-if="item.type == 1">
  29. <view class="title">{{ item.content }}</view>
  30. <view class="desc">绿马爱心公益助残基金</view>
  31. <view class="buy-box">
  32. <view class="num-box">
  33. <text class="company">¥</text>
  34. <text class="num">125.</text>
  35. <text class="float-num">05</text>
  36. </view>
  37. <button @click="goBuy(item)">{{item.msg_body.model_type == 0?'去购买':'去领取'}}</button>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <uni-popup class="tip-popup" ref="donationPopup" type="center" :mask-click="false">
  43. <view class="content-box">
  44. <view class="title">官方捐赠渠道</view>
  45. <view class="content">
  46. <view class="tip">
  47. 感谢您对绿马助残公益基金会支持,即将跳转到官方捐款渠道链接在线捐款。
  48. </view>
  49. <button class="btn donation">去捐赠</button>
  50. <view class="tip" style="color: #999999;">
  51. 注意:官方渠道捐赠完成之后需要在本平台申领公益积分
  52. </view>
  53. <view class="btn-box">
  54. <button @click="closePublicDonation()">知道了</button>
  55. <button @click="goApplyPointsPage()">去申领</button>
  56. </view>
  57. </view>
  58. </view>
  59. </uni-popup>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. props: {
  65. listData: {
  66. type: Array,
  67. default: () => {
  68. return []
  69. }
  70. }
  71. },
  72. data() {
  73. return {
  74. //枚举的消息类型
  75. typeList: [
  76. { text: '去捐赠',
  77. children: [
  78. {
  79. icon: '/static/common/msg-type1.png',
  80. text: '官方捐赠' //做公益-官方捐赠渠道
  81. },
  82. {
  83. icon: '/static/common/msg-type2.png',
  84. text: '公益捐赠' //做公益-积分捐赠
  85. },
  86. {
  87. icon: '/static/common/msg-type3.png',
  88. text: '公益捐赠', //做公益-公益捐赠
  89. welfareTypeList:[{
  90. // 捐款
  91. icon: '/static/common/msg-type1.png'
  92. },{
  93. // 捐物
  94. icon: '/static/common/msg-type3.png'
  95. }]
  96. }],
  97. },
  98. {
  99. text: '去购买'
  100. }
  101. ]
  102. }
  103. },
  104. methods: {
  105. goDonation(item){
  106. // 官方捐赠
  107. if(item.msg_body.model_type == 0){
  108. this.publicDonation();
  109. // 积分捐赠
  110. }else if(item.msg_body.model_type == 1){
  111. uni.navigateTo({
  112. url: '/pages/publicWelfare/index'
  113. })
  114. // 公益捐赠
  115. }else if(item.msg_body.model_type == 2){
  116. let token = uni.getStorageSync("apiToken")
  117. if (!token) {
  118. uni.navigateTo({
  119. url: "/pages/login/index"
  120. })
  121. return ;
  122. }
  123. uni.navigateTo({
  124. url: '/pages/publicDonation/index'
  125. })
  126. }
  127. },
  128. goBuy(item){
  129. uni.navigateTo({
  130. url: `/pages/product/goods/goods?id=${item.msg_body.goods_id}`
  131. })
  132. // 普通商品
  133. // if(item.msg_body.model_type == 0){
  134. // uni.navigateTo({
  135. // url: `/pages/product/goods/goods?id=${item.msg_body.goods_id}`
  136. // })
  137. // // 免费商品
  138. // }else if(item.msg_body.model_type == 1){
  139. // uni.navigateTo({
  140. // url: `/pages/product/goods/freeGoods?id=${item.msg_body.goods_id}`
  141. // })
  142. // }
  143. },
  144. //官方捐赠
  145. publicDonation(){
  146. this.$refs.donationPopup.open();
  147. },
  148. closePublicDonation(){
  149. this.$refs.donationPopup.close();
  150. },
  151. goApplyPointsPage(){
  152. let token = uni.getStorageSync("apiToken")
  153. if (!token) {
  154. uni.navigateTo({
  155. url: "/pages/login/index"
  156. })
  157. return ;
  158. }
  159. uni.navigateTo({
  160. url: '/pages/applyPoints/index'
  161. })
  162. }
  163. }
  164. };
  165. </script>
  166. <style lang="scss" scoped>
  167. .main {
  168. padding-bottom: 50rpx;
  169. .list {
  170. width: 690rpx;
  171. margin: 0 30rpx;
  172. background: #ffffff;
  173. border-radius: 16rpx;
  174. padding: 10rpx 20rpx;
  175. box-sizing: border-box;
  176. filter: drop-shadow(1px 2px 4px rgba(26, 58, 70, 0.1));
  177. .item,
  178. .item-2 {
  179. &:nth-child(1) {
  180. border-top: none;
  181. }
  182. border-top: 1px solid #e6e6e6;
  183. padding: 40rpx 0;
  184. display: flex;
  185. .cover {
  186. width: 226rpx;
  187. height: 226rpx;
  188. border-radius: 10rpx;
  189. margin-right: 25rpx;
  190. vertical-align: top;
  191. &-2 {
  192. width: 91rpx;
  193. height: 91rpx;
  194. border-radius: 10rpx;
  195. margin-right: 41rpx;
  196. vertical-align: top;
  197. }
  198. }
  199. .right,
  200. .right-2 {
  201. display: inline-block;
  202. flex: 1;
  203. //width: 400rpx;
  204. .title {
  205. // overflow: hidden;
  206. // text-overflow: ellipsis;
  207. // display: -webkit-box;
  208. // -webkit-line-clamp: 2;
  209. // -webkit-box-orient: vertical;
  210. font-size: 28rpx;
  211. line-height: calc(28rpx * 1.414);
  212. font-family: PingFang SC, PingFang SC-Regular;
  213. font-weight: 400;
  214. text-align: left;
  215. color: #181818;
  216. margin-top: 10rpx;
  217. text-align: justify;
  218. word-break: break-word;
  219. }
  220. .desc {
  221. flex: 1;
  222. font-size: 24rpx;
  223. font-family: PingFang SC, PingFang SC-Regular;
  224. font-weight: 400;
  225. text-align: left;
  226. color: #808080;
  227. line-height: 24rpx;
  228. margin-top: 10rpx;
  229. padding-right: 20rpx;
  230. box-sizing: border-box;
  231. // overflow: hidden;
  232. // white-space: nowrap;
  233. // text-overflow: ellipsis;
  234. }
  235. .buy-box {
  236. margin-top: 35rpx;
  237. display: flex;
  238. justify-content: space-between;
  239. .num-box {
  240. margin-top: 15rpx;
  241. .company,
  242. .float-num {
  243. font-size: 20rpx;
  244. font-family: PingFang SC, PingFang SC-Medium;
  245. font-weight: 500;
  246. text-align: left;
  247. color: #00bf5a;
  248. line-height: 24rpx;
  249. }
  250. .num {
  251. font-size: 36rpx;
  252. font-family: PingFang SC, PingFang SC-Medium;
  253. font-weight: bold;
  254. text-align: left;
  255. color: #00bf5a;
  256. line-height: 24rpx;
  257. }
  258. }
  259. .desc{
  260. line-height: 63rpx;
  261. margin-top: 0;
  262. }
  263. button {
  264. width: 138rpx;
  265. height: 63rpx;
  266. background: linear-gradient(180deg, #2eb82a, #027956);
  267. border-radius: 32rpx;
  268. font-size: 28rpx;
  269. font-family: PingFang SC, PingFang SC-Medium;
  270. font-weight: 500;
  271. text-align: left;
  272. color: #ffffff;
  273. line-height: 63rpx;
  274. text-align: center;
  275. }
  276. }
  277. }
  278. .right{
  279. .buy-box {
  280. margin-top: 50rpx
  281. }
  282. }
  283. }
  284. .item-2 {
  285. padding: 40rpx 0 50rpx 0;
  286. }
  287. }
  288. }
  289. </style>