redpacket_detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view class="page">
  3. <image src="../../static/img/repacket-top.png" class="topimg" ></image>
  4. <view class="topmenu" :style="'top:'+statusBarHeight">
  5. <uni-icons type='arrowleft' style="font-size: 34px;color: #fff;font-weight: 600;" @tap='goback()' ></uni-icons>
  6. </view>
  7. <view class="info">
  8. <view class="redpick-info">
  9. <view class="redpick-info-avatar">
  10. <view >
  11. <image :src="image_cache(item.sender.avatar)" style="border-radius: 12upx;" />
  12. <view class="redpick-info-nickname">{{item.sender.nickname}}</view>
  13. <view class="redpick-info-nickname">的红包</view>
  14. </view>
  15. </view>
  16. <view class="redpick-info-title" v-if="redpacket.money>0">
  17. <view class="money" style="color:#d0ac72;">
  18. <span style='font-size: 52px;font-weight: 600;'>{{redpacket.money}}</span>
  19. <span style='font-size: 16px;'>元</span>
  20. </view>
  21. <view style="color:#d0ac72;margin-top: 10px;font-size: 14px;text-decoration: underline;" @tap='gomoneylog'>已存到可用余额</view>
  22. </view>
  23. </view>
  24. <scroll-view scroll-x="false" scroll-y="true" class="scrollview">
  25. <view v-if="redpacket.isgroup==1 && redpacket.status==2" class='tips' >
  26. 共有<span class='num'>{{userlists.length}}</span>个红包,
  27. <span class='num'>{{lasttime}}</span>被抢光
  28. </view>
  29. <view class="friends" v-for="(m,index) in userlists" :key='index'>
  30. <view class="avatar">
  31. <image :src="image_cache(m.avatar)"></image>
  32. </view>
  33. <view class="showname">
  34. <view >
  35. {{m.nickname}}
  36. <span v-if="redpacket.isgroup==1 && redpacket.status==2 && m.money==max" style='color: #FF4400;margin-left: 5px;font-size: 14px;' >最佳</span>
  37. <view class="money">{{m.money}}元</view>
  38. </view>
  39. <view class="time">
  40. {{timestampToTime(m.time)}}
  41. </view>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import uniIcons from '../../components/uni-icons/uni-icons.vue'
  50. import http from '../../library/http.js'
  51. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 20 ;
  52. export default {
  53. components:{
  54. uniIcons
  55. },
  56. data() {
  57. return {
  58. statusBarHeight:statusBarHeight+'px',
  59. msg_id:0,
  60. storekey:'',
  61. user:uni.getStorageSync('userInfo'),
  62. item:{},
  63. redpacket:'',
  64. userlists:[],
  65. max:0,
  66. timeshow:0,
  67. info:'',
  68. lasttime:'',
  69. };
  70. },
  71. methods:{
  72. goback(){
  73. uni.navigateBack();
  74. },
  75. gomoneylog(){
  76. uni.navigateTo({
  77. url:'../mine/order'
  78. })
  79. },
  80. timestampToTime(timestamp) {
  81. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  82. var Y = date.getFullYear() ;
  83. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
  84. var D = date.getDate();
  85. var h = date.getHours();
  86. var m = date.getMinutes();
  87. var s = date.getSeconds();
  88. if(D<10) D='0'+D;
  89. if(h<10) h='0'+h;
  90. if(m<10) m='0'+m;
  91. if(s<10) s='0'+s;
  92. return Y+'-'+M+'-'+D+' '+h+':'+m+':'+s;
  93. },
  94. setuserinfo(){
  95. this.userlists=uni.getStorageSync('redpacket_users_'+this.redpacket.id)?uni.getStorageSync('redpacket_users_'+this.redpacket.id):[];
  96. this.info=uni.getStorageSync('redpacket_info_'+this.redpacket.id)?uni.getStorageSync('redpacket_info_'+this.redpacket.id):[];
  97. var endtime=0;
  98. for(var i=0;i<this.userlists.length;i++){
  99. if(this.userlists[i].money>this.max) this.max=this.userlists[i].money;
  100. if(this.userlists[i].time>this.max) endtime=this.userlists[i].time;
  101. }
  102. if(this.redpacket.isgroup==1 && this.redpacket.status==2 && endtime>this.info.addtime){
  103. var lasttime=endtime-this.info.addtime;
  104. if(lasttime<60) this.lasttime=lasttime+'秒';
  105. else if(lasttime<3600){
  106. this.lasttime=parseInt(lasttime/60)+'分';
  107. if(lasttime%60>0) this.lasttime+=lasttime%60+'秒';
  108. }else if(lasttime<86400){
  109. this.lasttime=parseInt(lasttime/3600)+'小时';
  110. lasttime=lasttime%3600;
  111. this.lasttime+=parseInt(lasttime/60)+'分';
  112. if(lasttime%60>0) this.lasttime+=lasttime%60+'秒';
  113. }
  114. else{
  115. this.lasttime=parseInt(lasttime/86400)+'天';
  116. lasttime=lasttime%86400;
  117. this.lasttime+=parseInt(lasttime/3600)+'小时';
  118. lasttime=lasttime%3600;
  119. this.lasttime+=parseInt(lasttime/60)+'分';
  120. if(lasttime%60>0) this.lasttime+=lasttime%60+'秒';
  121. }
  122. }
  123. },
  124. getinfo(){
  125. this.setuserinfo();
  126. http.setWait(false).get('group.php?act=redpacket_users',{id:this.redpacket.id}).then(res=>{
  127. if(res.code==200){
  128. uni.setStorageSync('redpacket_users_'+this.redpacket.id,res.data);
  129. uni.setStorageSync('redpacket_info_'+this.redpacket.id,res.info);
  130. this.setuserinfo();
  131. }
  132. else{
  133. uni.showToast({
  134. title:'网络异常,请稍后再试',
  135. icon:'none'
  136. })
  137. }
  138. })
  139. },
  140. },
  141. onLoad(opts) {
  142. this.msg_id=opts.msg_id;
  143. this.storekey=opts.storekey;
  144. var msgkey=this.user.id+"_chat_"+this.storekey;
  145. var msglist=uni.getStorageSync(msgkey);
  146. for(var i=0;i<msglist.length;i++){
  147. var msg=msglist[i];
  148. if(msg.msg_id==this.msg_id){
  149. this.item=msg;
  150. this.redpacket=msg.message.content
  151. try{
  152. this.redpacket=JSON.parse(this.redpacket)
  153. }catch(e){
  154. //TODO handle the exception
  155. }
  156. this.getinfo();
  157. break;
  158. }
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. .page{
  165. padding: 0px 0px;
  166. font-size: 14px;
  167. background-color: #FFF;
  168. }
  169. .topimg{
  170. position: fixed;
  171. width: 100%;
  172. height: 33vw;
  173. display: inline-block;
  174. left: 0px;
  175. top:0px;
  176. }
  177. .topmenu{
  178. position: fixed;
  179. width: calc(100% - 20px);
  180. height:50px;
  181. line-height: 50px;
  182. display: inline-block;
  183. left: 0px;
  184. padding-left: 10px;
  185. z-index: 1;
  186. text-align: left;
  187. }
  188. .info{
  189. position: fixed;
  190. width: 100%;
  191. height: auto;
  192. display: inline-block;
  193. left: 0px;
  194. top:34vw;
  195. z-index: 1;
  196. text-align: center;
  197. }
  198. .scrollview{
  199. position: fixed;
  200. width: calc(100% - 20px);
  201. height: 50vh;
  202. display: inline-block;
  203. left: 10px;
  204. bottom:0px;
  205. z-index: 2;
  206. text-align: center;
  207. }
  208. .tips{
  209. height: 30px;
  210. line-height: 30px;
  211. color: #666;
  212. font-size: 14px;
  213. padding-left: 10px;
  214. text-align: left;
  215. }
  216. .tips .num{
  217. color:#2319dc;
  218. font-weight: 600;
  219. margin: 0px 2px;
  220. }
  221. .friends{
  222. padding: 5px 0px;
  223. height: 35px;
  224. line-height: 35px;
  225. display: table;
  226. table-layout: fixed;
  227. width: calc(100% - 0px);
  228. }
  229. .friends .avatar{
  230. display: table-cell;
  231. width: 70px;
  232. text-align: center;
  233. }
  234. .friends .avatar image{
  235. height: 50px;
  236. width: 50px;
  237. border-radius: 5px;;
  238. vertical-align: middle;
  239. }
  240. .friends .showname {
  241. text-align:left;
  242. display: table-cell;
  243. font-size: 16px;
  244. color: #111;
  245. line-height: 25px;;
  246. vertical-align: middle;
  247. margin: 0px 0px;
  248. padding: 0px 0px;
  249. border-bottom: 1upx #EFEFEF solid;
  250. }
  251. .friends .showname .money{
  252. display: inline-block;float: right;
  253. }
  254. .friends .showname > view{
  255. width: 100%;
  256. height: 25px;
  257. line-height: 25px;
  258. }
  259. .friends .showname .time{
  260. color: #666;
  261. text-align: left;
  262. font-size: 12px;
  263. }
  264. .redpick-info{
  265. width: 100%;
  266. display: inline-block;
  267. color: #000;
  268. &-avatar{
  269. display: block;
  270. align-items: center;
  271. justify-content: center;
  272. margin-top: 10px;
  273. font-size: 28upx;
  274. image{
  275. width: 60upx;
  276. height:60upx;
  277. vertical-align: middle;
  278. margin-right: 5px;
  279. }
  280. }
  281. &-nickname{
  282. display: inline-block;
  283. max-width: 100px;
  284. max-width: 80%;
  285. text-overflow: ellipsis;
  286. white-space: nowrap;
  287. overflow: hidden;
  288. vertical-align: middle;
  289. }
  290. &-title{
  291. margin-top:10px;
  292. font-size: 40upx;
  293. }
  294. }
  295. .redpick-over{
  296. max-width: 80%;
  297. text-overflow: ellipsis;
  298. white-space: nowrap;
  299. overflow: hidden;
  300. display: block;
  301. margin: 0px auto;
  302. }
  303. </style>