myintegral.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view>
  3. <view class="padding bg-blue">
  4. <view class="text-center padding-top">
  5. <view class="text-sl padding-bottom-xs">{{userinfo.integral}}</view>
  6. <view>
  7. 可用积分
  8. <text data-name="tomoney" @tap="goPage('/pages/my/getmoney')" v-if="userparam.inttomoney>0">(我要兑现)</text>
  9. </view>
  10. <!-- #ifdef MP-WEIXIN -->
  11. <view class="margin-top-sm" v-if="userparam.intrecharge>0">
  12. <button class="cu-btn round" data-name="torecharge" @tap="showModal">积分充值</button>
  13. </view>
  14. <!-- #endif -->
  15. </view>
  16. <view class="flex solid-bottom padding-top justify-between">
  17. <view>上月获得:<text>{{monthintegral}}</text> 分</view>
  18. <view>累计已获:<text>{{userinfo.inttotal}}</text> 分</view>
  19. </view>
  20. </view>
  21. <view class="cu-list menu">
  22. <block v-for="(item,index) in plist" :key="index">
  23. <view class="cu-item">
  24. <view class="content padding-tb-sm padding-right-sm">
  25. <view>
  26. 【{{item.itype_text}}】
  27. {{item.title}}
  28. <block v-if="item.itype==3">(金额:¥{{item.intmoney}}元)</block>
  29. </view>
  30. <view class="text-gray text-sm">{{item.createtime}}</view>
  31. <view class="text-gray text-sm">
  32. <text class="padding-right-xs" v-if="item.itype==3 && item.status==1">[待处理]</text>
  33. <text class="padding-right-xs" v-if="item.itype==3 && item.status==2">[已成功]</text>
  34. <text class="padding-right-xs" v-if="item.itype==2 && item.status==1">[待支付]</text>
  35. <text class="padding-right-xs" v-if="item.itype==2 && item.status==2">[已成功]</text>
  36. {{item.remark}}
  37. </view>
  38. </view>
  39. <view class="action" v-if="item.intvalue>0">+{{item.intvalue}}</view>
  40. <view class="action" v-else>{{item.intvalue}}</view>
  41. </view>
  42. </block>
  43. </view>
  44. <uni-load-more :status="pstatus"></uni-load-more>
  45. <view class="cu-modal" :class="modalinfo.name=='tomoney'?'show':''">
  46. <view class="cu-dialog">
  47. <view class="cu-bar bg-white justify-end">
  48. <view class="content">兑现积分</view>
  49. <view class="action" @tap="hideModal">
  50. <text class="cuIcon-close text-grey"></text>
  51. </view>
  52. </view>
  53. <view class="padding-xl bg-white solid-top solid-bottom">
  54. <input type="number" placeholder="请输入兑现积分..." data-name="tomoneyvalue" @input="bindInput" :value="modalinfo.tomoneyvalue" />
  55. <view class="padding text-gray text-sm">{{userparam.inttomoney}}积分可兑现1元(最低提现积分额:{{userparam.minintegral}}积分)</view>
  56. </view>
  57. <view class="cu-bar bg-white justify-end">
  58. <view class="action">
  59. <button class="cu-btn line-grey text-grey" @tap="hideModal">取消</button>
  60. <button class="cu-btn bg-green margin-left" @tap="moneyModal">确定兑现</button>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="cu-modal" :class="modalinfo.name=='torecharge'?'show':''">
  66. <view class="cu-dialog">
  67. <view class="cu-bar bg-white justify-end">
  68. <view class="content">积分充值</view>
  69. <view class="action" @tap="hideModal">
  70. <text class="cuIcon-close text-grey"></text>
  71. </view>
  72. </view>
  73. <view class="padding-xl bg-white solid-top solid-bottom">
  74. <input type="number" placeholder="请输入充值金额..." data-name="torechargevalue" @input="bindInput" :value="modalinfo.torechargevalue" />
  75. <view class="padding-top padding-lr text-gray text-sm">当前充值金额可得:<text class="text-red padding-right-xs">{{userparam.intrecharge * parseFloat(modalinfo.torechargevalue)}}</text> 积分</view>
  76. <view class="padding text-gray text-sm">充值一元可得 {{userparam.intrecharge}} 积分(只支持整数金额)</view>
  77. </view>
  78. <view class="cu-bar bg-white justify-end">
  79. <view class="action">
  80. <button class="cu-btn line-grey text-grey" @tap="hideModal">取消</button>
  81. <button class="cu-btn bg-green margin-left" @tap="rechargeModal">确定支付</button>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
  90. var _this;
  91. export default {
  92. components: {
  93. uniLoadMore
  94. },
  95. data() {
  96. return {
  97. userparam: {},
  98. userinfo: {},
  99. monthintegral: 0,
  100. modalinfo: {
  101. name: null,
  102. tomoneyvalue: "",
  103. torechargevalue: ""
  104. },
  105. pstatus: 'more',
  106. ppage: 1,
  107. psize: 20,
  108. plist: []
  109. };
  110. },
  111. onLoad: function(){
  112. _this = this;
  113. _this.userinfo = _this.checkLogin("/pages/my/myintegral");
  114. if (_this.userinfo===false){
  115. return false;
  116. }
  117. _this.myIntegral();
  118. },
  119. onPullDownRefresh: function() {
  120. _this.ppage = 1;
  121. _this.pstatus = 'more';
  122. _this.plist = [];
  123. _this.getMore();
  124. },
  125. onReachBottom: function() {
  126. if (_this.pstatus !== 'more') {
  127. return;
  128. }
  129. _this.getMore();
  130. },
  131. methods: {
  132. // 填写字段
  133. hideModal: function() {
  134. _this.modalinfo.name = null;
  135. },
  136. showModal: function(e) {
  137. _this.modalinfo.name = e.currentTarget.dataset.name;
  138. },
  139. bindInput: function(e) {
  140. var name = e.currentTarget.dataset.name;
  141. _this.modalinfo[name] = e.detail.value;
  142. },
  143. moneyModal: function() {
  144. _this.$req.ajax({
  145. path: "my/getmoney",
  146. data: {
  147. intvalue: parseInt(_this.modalinfo.tomoneyvalue),
  148. userid: _this.userinfo.id
  149. }
  150. }).then((data) => {
  151. _this.userinfo = data.user;
  152. uni.startPullDownRefresh();
  153. _this.hideModal();
  154. }).catch((err) => {
  155. uni.showModal({
  156. title: '信息提示',
  157. content: err,
  158. showCancel: false
  159. });
  160. });
  161. },
  162. rechargeModal: function() {
  163. _this.$req.ajax({
  164. path: "my/getrecharge",
  165. data: {
  166. moneyvalue: _this.modalinfo.torechargevalue,
  167. userid: _this.userinfo.id
  168. }
  169. }).then((data) => {
  170. var payinfo = data.payinfo;
  171. uni.requestPayment({
  172. provider: 'wxpay',
  173. timeStamp: payinfo.timeStamp.toString(),
  174. nonceStr: payinfo.nonceStr,
  175. package: payinfo.package,
  176. signType: payinfo.signType,
  177. paySign: payinfo.paySign,
  178. success: function(res) {
  179. uni.showModal({
  180. title: '信息提示',
  181. content: '积分充值成功。',
  182. showCancel: false,
  183. success: function(res) {
  184. _this.ppage = 1;
  185. _this.pstatus = 'more';
  186. _this.plist = [];
  187. _this.myIntegral();
  188. _this.hideModal();
  189. }
  190. });
  191. },
  192. fail: function(err) {
  193. console.log('fail:' + JSON.stringify(err));
  194. }
  195. });
  196. _this.isRotate = false;
  197. }).catch((err) => {
  198. uni.showModal({
  199. title: '信息提示',
  200. content: err,
  201. showCancel: false
  202. });
  203. _this.isRotate = false;
  204. });
  205. },
  206. getMore: function() {
  207. _this.$req.ajax({
  208. path: "my/getintegral",
  209. data: {
  210. ppage: _this.ppage,
  211. psize: _this.psize,
  212. userid: _this.userinfo.id
  213. }
  214. }).then((data) => {
  215. _this.pstatus = data.pstatus;
  216. _this.plist = _this.plist.concat(data.plist);
  217. _this.ppage += 1;
  218. uni.stopPullDownRefresh();
  219. }).catch((err) => {
  220. uni.showModal({
  221. title: '信息提示',
  222. content: err,
  223. showCancel: false
  224. });
  225. });
  226. },
  227. myIntegral: function() {
  228. _this.$req.ajax({
  229. path: "my/myintegral",
  230. data: {
  231. userid: _this.userinfo.id
  232. }
  233. }).then((data) => {
  234. _this.userparam = data.userparam;
  235. _this.userinfo = data.user;
  236. _this.monthintegral = data.monthintegral;
  237. _this.getMore();
  238. }).catch((err) => {
  239. uni.showModal({
  240. title: '信息提示',
  241. content: err,
  242. showCancel: false
  243. });
  244. });
  245. },
  246. goPage: function(pageurl) {
  247. uni.navigateTo({
  248. url: pageurl,
  249. fail: function() {
  250. uni.switchTab({
  251. url: pageurl
  252. });
  253. }
  254. });
  255. },
  256. }
  257. }
  258. </script>
  259. <style>
  260. </style>