index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <view class="main">
  3. <view class="pageTop">
  4. <navbar ref="navbar" :config="config"></navbar>
  5. <view class="dataCls">
  6. <view class="dataCls_l">
  7. <view class="dataCls_l_num">{{loveData.love_value}}</view>
  8. <view>爱心数(颗)</view>
  9. <view>累计爱心值:{{loveData.cumulative_love_value}}</view>
  10. </view>
  11. <view class="dataCls_r">
  12. <view @click="open()">兑换公益积分</view>
  13. </view>
  14. </view>
  15. <view class="shadeBox"></view>
  16. </view>
  17. <view class="listBox">
  18. <view class="listBox_title">
  19. <view>
  20. <view class="listBox_line"></view>
  21. <view class="listBox_circle"></view>
  22. </view>
  23. <view class="listBox_title_text">爱心明细</view>
  24. <view>
  25. <view class="listBox_circle"></view>
  26. <view class="listBox_line2"></view>
  27. </view>
  28. </view>
  29. <view class="list_item" v-for="(v,i) in list" :key="i">
  30. <view class="list_item_l">
  31. <view class="list_item_l_text">{{v.remark}}</view>
  32. <view class="list_item_l_time">{{v.create_time.substr(0,10)}}</view>
  33. </view>
  34. <view class="list_item_r c_green" :class="{c_red:!v.bill_type}">{{v.bill_type?'+':'-'}} {{v.value}}
  35. </view>
  36. </view>
  37. <view class="loadmoreBox">
  38. <u-loadmore :status="status" />
  39. </view>
  40. </view>
  41. <!-- 兑换弹窗 -->
  42. <u-popup v-model="show" mode="center" border-radius="10">
  43. <view class="popBox">
  44. <view class="popBox_title">请确认兑换额度</view>
  45. <view class="popBox_center">
  46. <view class="popBox_inpBox">
  47. <view class="popBox_inp">
  48. <input type="text" @input="intNum" v-model="loveValue">
  49. </view>
  50. <view class="popBox_inp_all" @click="inpAll">全部</view>
  51. </view>
  52. <view class="popBox_tig">规则:当前兑换比例为{{pointsConfig.love_value}}:{{pointsConfig.public_welfare_integral}}</view>
  53. <view class="popBox_btnBox">
  54. <view class="popBox_btnBox_close" @click="close">关闭</view>
  55. <view class="popBox_btnBox_confirm" @click="loveValueExchange()">确认兑换</view>
  56. </view>
  57. </view>
  58. </view>
  59. </u-popup>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. config: {
  67. back: true, //false是tolbar页面 是则不写
  68. title: '我的爱心',
  69. color: '#ffffff',
  70. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  71. backgroundColor: [0, 'transparent'],
  72. statusBarFontColor: '#ffffff',
  73. rightSlot: true,
  74. },
  75. status: "nomore",
  76. show: false,
  77. totalPage: 0,
  78. list: [],
  79. param: {
  80. page: 1,
  81. limit: 10
  82. },
  83. loveValue: "",
  84. loveData:{},
  85. pointsConfig:{}
  86. }
  87. },
  88. onLoad() {
  89. this.getList();
  90. this.getData();
  91. this.getPointsConfig()
  92. },
  93. onPullDownRefresh() {
  94. this.getList();
  95. this.getData()
  96. },
  97. onReachBottom() {
  98. if (this.status == "loadmore") {
  99. this.param.page++
  100. }
  101. this.getList();
  102. },
  103. methods: {
  104. open() {
  105. this.show = true;
  106. this.loveValue = "";
  107. },
  108. close() {
  109. this.show = false;
  110. this.loveValue = "";
  111. },
  112. getData() {
  113. this.$http.get('/account/app-account-info').then(res => {
  114. if (res && res.code == 200) {
  115. this.loveData=res.data
  116. }
  117. })
  118. },
  119. // 只允许输入整数
  120. intNum(e){
  121. this.$nextTick(()=>{
  122. this.loveValue=parseInt(e.detail.value)||''
  123. })
  124. },
  125. // 获取比例规则
  126. getPointsConfig(){
  127. this.$http.get('/points/exchange/config/info').then(res=>{
  128. if(res&&res.code==200){
  129. this.pointsConfig=res.data
  130. }
  131. })
  132. },
  133. // 输入全部积分
  134. inpAll(){
  135. this.loveValue=this.loveData.love_value
  136. },
  137. // 爱心明细
  138. getList() {
  139. this.status = "loading"
  140. this.param.page=1;
  141. this.$http.get('/user/love/record/page', this.param).then(res => {
  142. if (res && res.code == 200) {
  143. this.list = res.page.list;
  144. this.totalPage = res.page.totalPage;
  145. if (this.totalPage > this.list.length) {
  146. this.status = "loadmore"
  147. } else {
  148. this.status = "nomore"
  149. }
  150. uni.stopPullDownRefresh()
  151. }
  152. })
  153. },
  154. // 兑换
  155. loveValueExchange() {
  156. if(!this.loveValue){
  157. uni.showToast({
  158. icon:"none",
  159. title: '请输入兑换爱心值!',
  160. duration: 2000
  161. });
  162. return false
  163. }
  164. this.$http.post(`/user/love/record/loveValueExchange/${this.loveValue}`).then((res => {
  165. if (res && res.code == 200) {
  166. uni.showToast({
  167. title: '兑换成功!',
  168. duration: 2000
  169. });
  170. this.close()
  171. this.getList()
  172. this.getData()
  173. }
  174. }))
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss">
  180. .pageTop {
  181. width: 100%;
  182. height: 450rpx;
  183. background: url('/static/convenienceService/detailsBg.png')0 0 no-repeat;
  184. background-size: 752rpx 510rpx;
  185. position: relative;
  186. /deep/ .hx-navbar__fixed {
  187. background: url('/static/convenienceService/detailsBg.png')0 0 no-repeat;
  188. background-size: 752rpx 510rpx;
  189. }
  190. .dataCls {
  191. display: flex;
  192. justify-content: space-between;
  193. padding: 0 60rpx;
  194. margin-top: 80rpx;
  195. .dataCls_l {
  196. font-size: 28rpx;
  197. color: #F5F5F5;
  198. line-height: 40rpx;
  199. .dataCls_l_num {
  200. font-size: 38rpx;
  201. }
  202. }
  203. .dataCls_r {
  204. display: flex;
  205. align-items: center;
  206. view {
  207. font-size: 28rpx;
  208. color: #0B844A;
  209. padding: 20rpx 30rpx;
  210. border-radius: 40rpx;
  211. background: #ffffff;
  212. margin-bottom: 20rpx;
  213. }
  214. }
  215. }
  216. .shadeBox {
  217. width: 100%;
  218. height: 40rpx;
  219. background: #ffffff;
  220. border-radius: 40rpx 40rpx 0 0;
  221. position: absolute;
  222. bottom: 0;
  223. left: 0;
  224. }
  225. }
  226. .listBox {
  227. padding: 0 60rpx;
  228. .listBox_title {
  229. display: flex;
  230. justify-content: center;
  231. padding-bottom: 30rpx;
  232. >view {
  233. display: flex;
  234. align-items: center;
  235. }
  236. .listBox_title_text {
  237. font-size: 30rpx;
  238. color: #0D8748;
  239. font-weight: 700;
  240. margin: 0 30rpx;
  241. letter-spacing: 2rpx;
  242. }
  243. .listBox_line {
  244. width: 60rpx;
  245. height: 2rpx;
  246. background: linear-gradient(90deg, #ffffff, #0d8748);
  247. border-radius: 1rpx;
  248. }
  249. .listBox_line2 {
  250. width: 60rpx;
  251. height: 2rpx;
  252. background: linear-gradient(270deg, #ffffff, #0d8748);
  253. border-radius: 1rpx;
  254. }
  255. .listBox_circle {
  256. width: 6rpx;
  257. height: 6rpx;
  258. background: #0d8748;
  259. border-radius: 50%;
  260. }
  261. }
  262. .list_item {
  263. display: flex;
  264. justify-content: space-between;
  265. align-items: center;
  266. border-bottom: 1rpx solid #E6E6E6;
  267. padding: 30rpx 0;
  268. .list_item_l {
  269. flex: 1;
  270. .list_item_l_text {
  271. font-size: 28rpx;
  272. color: #1A1A1A;
  273. }
  274. .list_item_l_time {
  275. font-size: 24rpx;
  276. color: #999999;
  277. margin-top: 10rpx;
  278. }
  279. }
  280. .list_item_r {
  281. font-size: 30rpx;
  282. }
  283. }
  284. .loadmoreBox {
  285. display: flex;
  286. justify-content: center;
  287. padding: 30rpx;
  288. }
  289. }
  290. .popBox {
  291. width: 490rpx;
  292. .popBox_title {
  293. background: #E6E6E6;
  294. font-size: 30rpx;
  295. color: #1A1A1A;
  296. padding: 25rpx 0;
  297. font-weight: 700;
  298. text-align: center;
  299. }
  300. .popBox_center {
  301. padding: 70rpx 27rpx;
  302. .popBox_inpBox {
  303. display: flex;
  304. text-align: center;
  305. .popBox_inp {
  306. border-left: 1rpx solid #cccccc;
  307. border-top: 1rpx solid #cccccc;
  308. border-bottom: 1rpx solid #cccccc;
  309. border-radius: 10rpx 0 0 10rpx;
  310. padding: 10rpx 0;
  311. }
  312. .popBox_inp_all {
  313. display: flex;
  314. align-items: center;
  315. background: #20A634;
  316. font-size: 28rpx;
  317. color: #FFFFFF;
  318. padding: 10rpx 30rpx;
  319. flex-shrink: 0;
  320. border-radius: 0rpx 10rpx 10rpx 0rpx;
  321. }
  322. }
  323. .popBox_tig {
  324. font-size: 26rpx;
  325. color: #999999;
  326. letter-spacing: 2rpx;
  327. margin-top: 25rpx;
  328. }
  329. }
  330. .popBox_btnBox {
  331. display: flex;
  332. justify-content: space-between;
  333. margin-top: 37rpx;
  334. >view {
  335. width: 200rpx;
  336. height: 80rpx;
  337. border: 1rpx solid #20a634;
  338. border-radius: 41rpx;
  339. display: flex;
  340. justify-content: center;
  341. align-items: center;
  342. font-size: 32rpx;
  343. letter-spacing: 2rpx;
  344. }
  345. .popBox_btnBox_close {
  346. color: #20A634;
  347. }
  348. .popBox_btnBox_confirm {
  349. background: #20A634;
  350. color: #ffffff;
  351. }
  352. }
  353. }
  354. .c_red {
  355. color: #FF3B3B !important;
  356. }
  357. .c_green {
  358. color: #118D44;
  359. }
  360. </style>