info4.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view class="InviteFriends">
  3. <ujp-navbar title="朋友圈集赞领优惠券"></ujp-navbar>
  4. <view class="InviteFriends-head">
  5. <u-image width="298rpx" class="img1" height="64rpx" src="@/assets/static/img/logo3Ud.png"></u-image>
  6. <u-image width="350rpx" class="img2" style="margin-top: 28rpx ;" height="142rpx"
  7. src="@/assets/img/20250625/info3-1.png"></u-image>
  8. </view>
  9. <view class="body">
  10. <view class="title">活动时间:</view>
  11. <view class="text">2025年7月10日至7月24日</view>
  12. <view class="title">活动规则:</view>
  13. <view class="text">转发
  14. <span style="color: red;">本次活动推文至朋友圈</span>,集齐18个赞,可领<span
  15. style="color: red;">10元服务费抵扣券</span>,限{{totalNum}}张,领完即止, 先后顺序以上传时间为准。(每个微信仅可参与1次)
  16. </view>
  17. <view class="title"><span style="color: red;">*</span>上传截图(仅需上传1张截图)</view>
  18. <view class="text">
  19. <view class="cameraImg" v-if="!authImg" @click="uploadPhoto">
  20. <img class="camera" src="@/assets/img/camera-fill.svg" alt="">
  21. </view>
  22. <view class="cameraImg2" v-else @click="uploadPhoto">
  23. <img class="camera" :src="authImg" alt="">
  24. </view>
  25. <u-button type="info" v-if="totalNum<=examineNum"
  26. shape="circle">活动已结束</u-button>
  27. <u-button type="warning" v-else-if="byUser.length==0" @click="submit"
  28. shape="circle">提交</u-button>
  29. <u-button type="info" v-else
  30. shape="circle">已提交</u-button>
  31. </view>
  32. <view class="title">您的进度:</view>
  33. <view class="text">
  34. <u-steps :list="numList" active-color="#00B962" mode="number" :current="current"></u-steps>
  35. </view>
  36. </view>
  37. <view class="body">
  38. <view class="title">发放记录<span style="color: red;" v-if="totalNum>examineNum">(仅剩{{totalNum-examineNum}}张)</span> </view>
  39. <view class="list">
  40. <view class="item" v-for="(item,index) in informationList" :key="index" v-show="showBt||index<5">
  41. <view class="name">
  42. <u-avatar src="@/assets/img/head.png" size="48"></u-avatar>
  43. {{substringTxt(item.createByName,1)}}******
  44. </view>
  45. <view class="phone">
  46. {{substringTxt(item.phone,3)}}******
  47. </view>
  48. <view class="time">
  49. {{formatTimeAgo(item.createTime)}}
  50. </view>
  51. </view>
  52. </view>
  53. <u-divider margin-top="20" bg-color="#F2F4F4" @click="showBt=true" v-if="!showBt&&informationList.length>5">点击查看全部</u-divider>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import * as API from '@/apis/temporary.js'
  59. export default {
  60. data() {
  61. return {
  62. authImg: "",
  63. current: -1,
  64. numList: [{
  65. name: '提交截图'
  66. }, {
  67. name: '后台审核'
  68. }, {
  69. name: '发放奖券'
  70. }, ],
  71. informationList:[],
  72. acInfo:{},
  73. byUser:{},
  74. totalNum:0,
  75. examineNum:0,
  76. showBt:false,
  77. }
  78. },
  79. onReady() {
  80. this.getInfo()
  81. this.getList()
  82. },
  83. methods: {
  84. formatTimeAgo(inputTime) {
  85. // 转换输入为Date对象
  86. const inputDate = typeof inputTime === 'string'
  87. ? new Date(inputTime)
  88. : inputTime;
  89. // 计算时间差(毫秒)
  90. const now = new Date();
  91. const diffMs = now - inputDate;
  92. // 各时间单位的毫秒数
  93. const minuteMs = 60 * 1000;
  94. const hourMs = 60 * minuteMs;
  95. const dayMs = 24 * hourMs;
  96. // 根据时间差返回不同格式
  97. if (diffMs < minuteMs) {
  98. return '刚刚';
  99. } else if (diffMs < hourMs) {
  100. const minutes = Math.floor(diffMs / minuteMs);
  101. return `${minutes}分钟前`;
  102. } else if (diffMs < dayMs) {
  103. const hours = Math.floor(diffMs / hourMs);
  104. return `${hours}小时前`;
  105. } else {
  106. const days = Math.floor(diffMs / dayMs);
  107. return `${days}天前`;
  108. }
  109. },
  110. substringTxt(t,num){
  111. if(t){
  112. return t.substring(0,num)
  113. }else{
  114. return ''
  115. }
  116. },
  117. submit(){
  118. if(this.byUser.length){
  119. return
  120. }
  121. if(!this.authImg){
  122. uni.showToast({
  123. title: "请上传朋友圈点赞截图"
  124. })
  125. return
  126. }
  127. var obj=[{"name":"","value":this.authImg,"type":"img"}]
  128. uni.showLoading({
  129. title: "加载中",
  130. mask: true,
  131. })
  132. API.loginSubmit({
  133. openId:this.carhelp.getOpenId(),
  134. type:"3",
  135. content:JSON.stringify(obj)
  136. }).then((res) => {
  137. //this.byUser = res.data.helpList
  138. uni.showModal({
  139. title:"提示",
  140. content: "操作成功",
  141. showCancel: false,
  142. success: res => {
  143. }
  144. })
  145. uni.hideLoading()
  146. this.getInfo()
  147. }).catch(error => {
  148. uni.showToast({
  149. title: error
  150. })
  151. })
  152. },
  153. getInfo(){
  154. uni.showLoading({
  155. title: "加载中",
  156. mask: true,
  157. })
  158. API.informationByUser({
  159. type:"3"
  160. }).then((res) => {
  161. this.byUser = res.data.joinList
  162. if(this.byUser.length){
  163. this.current=0
  164. var item= this.byUser[0]
  165. if(item.examine){
  166. this.current=1
  167. if(item.status){
  168. this.current=2
  169. }
  170. }
  171. }
  172. uni.hideLoading()
  173. }).catch(error => {
  174. uni.showToast({
  175. title: error
  176. })
  177. })
  178. },
  179. getList(){
  180. API.informationList({
  181. type:"3",
  182. pageSize:200
  183. }).then((res) => {
  184. this.informationList = res.data.joinList
  185. this.informationList =this.informationList.sort((a1,a2)=>{
  186. return a1.createTime>a2.createTime?-1:1
  187. })
  188. this.examineNum=res.data.examineNum
  189. this.totalNum=res.data.totalNum
  190. // this.examineNum=100
  191. // this.totalNum=99
  192. }).catch(error => {
  193. uni.showToast({
  194. title: error
  195. })
  196. })
  197. },
  198. uploadPhoto() {
  199. if(this.byUser.length||this.totalNum<=this.examineNum){
  200. return
  201. }
  202. uni.chooseImage({
  203. count: 1,
  204. sizeType: ['compressed'],
  205. success: async (res) => {
  206. console.log(res)
  207. var imageSrc = res.tempFilePaths[0]
  208. this.uploadFile(imageSrc);
  209. },
  210. fail: (err) => {
  211. console.log('chooseImage fail', err)
  212. }
  213. })
  214. },
  215. uploadFile(imageSrc) {
  216. var action = process.car.BASE_URL + "uploadPicture"
  217. var token = this.carhelp.getToken()
  218. var header = {
  219. 'Authorization': token
  220. }
  221. var formData = {
  222. subFolder: "/team51/20250625v4"
  223. }
  224. var _this = this
  225. uni.showLoading({
  226. title: '上传中'
  227. })
  228. uni.uploadFile({
  229. url: action, //仅为示例,非真实的接口地址
  230. filePath: imageSrc,
  231. name: 'photoFile',
  232. header: header,
  233. formData: formData,
  234. success: (res) => {
  235. uni.hideLoading();
  236. uni.showToast({
  237. title: '上传成功',
  238. icon: 'success',
  239. duration: 1000
  240. })
  241. _this.authImg = JSON.parse(res.data).data
  242. _this.$forceUpdate()
  243. },
  244. fail: (err) => {
  245. console.log('uploadImage fail', err);
  246. uni.hideLoading();
  247. uni.showModal({
  248. content: err.errMsg,
  249. showCancel: false
  250. });
  251. },
  252. });
  253. },
  254. }
  255. }
  256. </script>
  257. <style lang="scss" scoped>
  258. .InviteFriends {
  259. background: linear-gradient(180deg, rgba(31, 85, 255, 1) 0%, rgba(39, 171, 255, 1) 100%);
  260. padding-bottom: 160rpx;
  261. }
  262. .InviteFriends-head {
  263. display: flex;
  264. flex-direction: column;
  265. align-items: center;
  266. .img1 {
  267. margin-top: 52rpx;
  268. }
  269. }
  270. .body {
  271. border-radius: 16px;
  272. background-color: rgba(255, 255, 255, 1);
  273. padding: 40rpx 36rpx;
  274. margin: 48rpx;
  275. .title {
  276. font-size: 36rpx;
  277. margin-bottom: 16rpx;
  278. color: rgba(16, 16, 16, 1);
  279. font-weight: bold;
  280. }
  281. .text {
  282. margin-bottom: 40rpx;
  283. font-size: 28rpx;
  284. color: rgba(51, 51, 51, 1);
  285. }
  286. .list {
  287. margin-top: 24rpx;
  288. .item {
  289. display: flex;
  290. justify-content: space-between;
  291. margin-bottom: 16rpx;
  292. align-items: center;
  293. .name {
  294. display: flex;
  295. align-items: center;
  296. }
  297. }
  298. }
  299. }
  300. .cameraImg {
  301. background-color: #D5D7D9;
  302. width: 160rpx;
  303. height: 160rpx;
  304. border-radius: 4px;
  305. padding: 60rpx;
  306. margin-bottom: 40rpx;
  307. }
  308. .cameraImg2 {
  309. background-color: #D5D7D9;
  310. border-radius: 4px;
  311. //padding: 60rpx;
  312. margin-bottom: 40rpx;
  313. width: 160rpx;
  314. height: 160rpx;
  315. .camera{
  316. width: 160rpx;
  317. height: 160rpx;
  318. }
  319. }
  320. </style>