sj.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="content">
  3. <template v-if="list.length > 0">
  4. <view class="u-wrap flex" v-for="item in list" @click="changeLevel(item)">
  5. <view class="">
  6. <view class="name flex" v-if="is_buy == 0">
  7. {{item.name}}
  8. <image :src="item.icon" mode="heightFix"></image>
  9. </view>
  10. <view class="name flex" v-else>
  11. 开店次数:{{item.open_store}}
  12. </view>
  13. <view class="" v-if="is_buy == 0">
  14. 价格:{{(item.money*1 - (userInfo.pay_store*1 || 0)).toFixed(2) }}
  15. </view>
  16. <view class="" v-else>
  17. 价格:{{item.money*1 }}
  18. </view>
  19. <!-- <view class="">
  20. 下一等级:XXX
  21. </view> -->
  22. <view class="choose choosed" v-if="chooseLevel.id == item.id">
  23. </view>
  24. <view class="choose" v-else >
  25. </view>
  26. </view>
  27. </view>
  28. <view class="btn flex" @click="upLevel">
  29. {{is_buy == 0? '立即升级':'立即购买'}}
  30. </view>
  31. </template>
  32. <empty v-if="list.length == 0"></empty>
  33. </view>
  34. </template>
  35. <script>
  36. import empty from '@/components/empty';
  37. import {
  38. getUserInfo,
  39. } from '@/api/user.js';
  40. import { getPayGrade,upLevel,upStore} from '@/api/work.js'
  41. export default {
  42. components: {
  43. empty
  44. },
  45. data() {
  46. return {
  47. is_buy: 0,
  48. loading: true,
  49. list: [],
  50. chooseLevel: {id: 0},
  51. userInfo: {level: 0},
  52. }
  53. },
  54. onLoad(opt) {
  55. if(opt.is_buy) {
  56. this.is_buy = opt.is_buy
  57. }
  58. this.getUserInfo()
  59. },
  60. onShow() {
  61. },
  62. onReachBottom() {
  63. },
  64. onReady() {
  65. },
  66. methods: {
  67. changeLevel(item) {
  68. this.chooseLevel = item
  69. },
  70. getPayGrade() {
  71. let that = this
  72. getPayGrade().then(res => {
  73. if(that.is_buy == 1) {
  74. this.list = res.data.filter(item => {
  75. return item.id <= that.userInfo.level
  76. })
  77. }else {
  78. this.list = res.data.filter(item => {
  79. return item.id > that.userInfo.level
  80. })
  81. }
  82. this.loading = false
  83. })
  84. },
  85. getUserInfo() {
  86. getUserInfo().then(res => {
  87. this.userInfo = res.data
  88. this.getPayGrade()
  89. })
  90. },
  91. upLevel() {
  92. let that = this
  93. if(that.loading) return;
  94. if(!that.chooseLevel.id) {
  95. if(that.is_buy == 1) {
  96. return that.$api.msg('请选择需要购买的开店次数')
  97. }else {
  98. return that.$api.msg('请选择需要升级的等级')
  99. }
  100. }
  101. that.loading = true
  102. uni.showModal({
  103. content:that.is_buy == 1? ('您确定要购买' + that.chooseLevel.open_store+ '次开店次数'): ('您确定要升级为' + that.chooseLevel.name + '?'),
  104. complete(res) {
  105. if(res.confirm) {
  106. uni.showLoading({
  107. title:'支付中...'
  108. })
  109. let buyLevel;
  110. if(that.is_buy == 1) {
  111. buyLevel = upStore
  112. }else {
  113. buyLevel = upLevel
  114. }
  115. buyLevel({
  116. from: 'H5',
  117. pay_type: 'yue',
  118. level_id: that.chooseLevel.id
  119. }).then(res => {
  120. that.$set(that,'chooseLevel',{id: 0})
  121. console.log(res)
  122. uni.hideLoading()
  123. that.$success(that.is_buy == 0? '升级成功':'购买成功')
  124. that.getUserInfo()
  125. // that.getPayGrade()
  126. }).catch(err => {
  127. that.loading = false
  128. uni.hideLoading()
  129. })
  130. }
  131. }
  132. })
  133. },
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .content {
  139. // background-image: url('../../static/work/sj-bg.png');
  140. background-color: #fff;
  141. background-size: 100% 100%;
  142. background-repeat: no-repeat;
  143. height: calc(100vh - 44px);
  144. padding-top: 20rpx;
  145. }
  146. .btn {
  147. width: 603rpx;
  148. height: 92rpx;
  149. background: linear-gradient(0deg, rgba(255,109,11,0.96), rgba(255,179,53,0.96));
  150. border-radius: 46rpx;
  151. border: 1px solid #FFFFFF;
  152. margin: 50rpx auto;
  153. justify-content: center;
  154. font-weight: bold;
  155. font-size: 35rpx;
  156. color: #FFFFFF;
  157. }
  158. .u-wrap {
  159. width: 672rpx;
  160. height: 181rpx;
  161. background: #FFF7E5;
  162. box-shadow: 5rpx 7rpx 6rpx 0rpx rgba(253,170,113,0.29);
  163. border-radius: 36rpx;
  164. border: 2px solid #FFFFFF;
  165. margin:20rpx auto;
  166. justify-content: flex-start;
  167. padding-left: 50rpx;
  168. position: relative;
  169. .logo {
  170. width: 130rpx;
  171. height: 130rpx;
  172. margin-right: 23rpx;
  173. background-color: #eee;
  174. border-radius: 50%;
  175. }
  176. font-weight: bold;
  177. font-size: 24rpx;
  178. color: #30333B;
  179. .name {
  180. font-size: 30rpx;
  181. padding-bottom: 20rpx;
  182. image {
  183. height: 38rpx;
  184. margin-left: 10rpx;
  185. }
  186. }
  187. }
  188. .choose {
  189. width: 41rpx;
  190. height: 41rpx;
  191. background: #F6F6F6;
  192. border: 1px solid #CCCCCC;
  193. border-radius: 50%;
  194. position: absolute;
  195. bottom: 50rpx;
  196. right: 24rpx;
  197. }
  198. .choosed {
  199. background-image: url('../../static/work/choose.png');
  200. background-size: 100% 100%;
  201. border: none;
  202. }
  203. </style>