userInfor.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="userInfor acea-row row-between-wrapper" :class="{pageOn:itemStyle===0}"
  3. :style="{marginLeft:prConfig+'rpx',marginRight:prConfig+'rpx',marginTop:mbCongfig+'rpx',background:bgColor}" v-show="!isSortType" @click="goLogin">
  4. <view class="left acea-row row-middle">
  5. <view class="pictrue acea-row row-center-wrapper">
  6. <image :src="diyInfo.avatar" v-if="diyInfo.avatar && isLogin"></image>
  7. <image v-if="!diyInfo.avatar && isLogin" src="@/static/images/f.png"></image>
  8. <image v-if="!isLogin" src="@/static/images/f.png"></image>
  9. </view>
  10. <view class="text">
  11. <view v-if="!isLogin" class="name">点击登录</view>
  12. <view v-else class="name">{{diyInfo.nickname}}</view>
  13. <view class="acea-row row-middle" v-if="isLogin">
  14. <view class="progress">
  15. <view class='bg-reds' :style="'width:'+(diyInfo.exp>diyInfo.next_exp?100:$util.$h.Div(parseInt(diyInfo.exp), diyInfo.next_exp)>=5?$util.$h.Div(parseInt(diyInfo.exp), diyInfo.next_exp):5)+'%;'"></view>
  16. </view>
  17. <view class="percent">{{diyInfo.exp?diyInfo.exp.split('.')[0]:0}}/{{diyInfo.next_exp}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="right acea-row row-bottom">
  22. <view class="item" v-if="diyInfo.level>0 && checkType.indexOf(1) != -1" @click.stop="goIntegral">
  23. <view class="num">{{diyInfo.integral||2}}</view>
  24. <view>积分</view>
  25. </view>
  26. <view class="item" v-if="diyInfo.level>0 && checkType.indexOf(2) != -1" @click.stop="goMoney">
  27. <view class="num">{{diyInfo.now_money||6}}</view>
  28. <view>余额</view>
  29. </view>
  30. <view class="item" v-if="checkType.indexOf(0) != -1" @click.stop="goCoupon">
  31. <view class="num">{{diyInfo.coupon_num||0}}</view>
  32. <view>优惠券</view>
  33. </view>
  34. <view class="item" v-if="(diyInfo.level == 0 && checkType.indexOf(3) != -1) || !isLogin" @click.stop="tapQrCode">
  35. <view class="iconfont icon-erweima3"></view>
  36. <view>会员码</view>
  37. </view>
  38. </view>
  39. <view class="codePopup" :style="colorStyle" v-show="isCode">
  40. <view class="header acea-row row-between-wrapper">
  41. <view class="title" :class="{'on': codeIndex == index,'onLeft':codeIndex == 1}"
  42. v-for="(item, index) in codeList" :key="index" @click="tapCode(index)">{{item.name}}</view>
  43. </view>
  44. <view>
  45. <view class="acea-row row-center-wrapper">
  46. <w-barcode :options="config.bar"></w-barcode>
  47. </view>
  48. <view class="acea-row row-center-wrapper" style="margin-top: 35rpx;">
  49. <w-qrcode :options="config.qrc" @generate="hello"></w-qrcode>
  50. </view>
  51. <view class="codeNum">{{config.bar.code}}</view>
  52. <view class="tip">如遇到扫码失败请将屏幕调至最亮重新扫码</view>
  53. </view>
  54. <view class="iconfont icon-guanbi2" @click="closeCode"></view>
  55. </view>
  56. <view class="mark" v-if="isCode"></view>
  57. </view>
  58. </template>
  59. <script>
  60. import colors from "@/mixins/color";
  61. import {
  62. diyUserInfo
  63. } from '@/api/api.js';
  64. import {
  65. toLogin
  66. } from '@/libs/login.js';
  67. import {
  68. getRandCode
  69. } from '@/api/user.js';
  70. import {
  71. mapGetters
  72. } from 'vuex';
  73. export default {
  74. computed: mapGetters(['isLogin']),
  75. name: 'userInfor',
  76. props: {
  77. dataConfig: {
  78. type: Object,
  79. default: () => {}
  80. },
  81. isSortType: {
  82. type: String | Number,
  83. default: 0
  84. }
  85. },
  86. mixins: [colors],
  87. data() {
  88. return {
  89. config: {
  90. bar: {
  91. code: '',
  92. color: ['#000'],
  93. bgColor: '#FFFFFF', // 背景色
  94. width: 480, // 宽度
  95. height: 110 // 高度
  96. },
  97. qrc: {
  98. code: '',
  99. size: 380, // 二维码大小
  100. level: 3, //等级 0~4
  101. bgColor: '#FFFFFF', //二维码背景色 默认白色
  102. border: {
  103. color: ['#eee', '#eee'], //边框颜色支持渐变色
  104. lineWidth: 3, //边框宽度
  105. },
  106. // img: '/static/logo.png', //图片
  107. // iconSize: 40, //二维码图标的大小
  108. color: ['#333', '#333'], //边框颜色支持渐变色
  109. }
  110. },
  111. codeList: [{
  112. name: '会员码'
  113. }, {
  114. name: '付款码'
  115. }],
  116. codeIndex: 0,
  117. isCode: false,
  118. bgColor: this.dataConfig.bgColor.color[0].item,
  119. mbCongfig: this.dataConfig.mbCongfig.val*2,
  120. prConfig: this.dataConfig.prConfig.val*2, //背景边距
  121. itemStyle: this.dataConfig.itemStyle.type,
  122. checkType: this.dataConfig.checkboxInfo.type,
  123. diyInfo:{}
  124. }
  125. },
  126. created() {},
  127. mounted() {
  128. if (this.isLogin) {
  129. this.getDiyUserInfo();
  130. }
  131. },
  132. methods: {
  133. hello(res) {
  134. // console.log(321,res)
  135. },
  136. getCode() {
  137. getRandCode().then(res => {
  138. let code = res.data.code;
  139. this.config.bar.code = code;
  140. this.config.qrc.code = code;
  141. }).catch(err => {
  142. return this.$util.Tips(err);
  143. })
  144. },
  145. tapQrCode() {
  146. if(this.isLogin){
  147. this.isCode = true;
  148. this.codeIndex = 0;
  149. this.$nextTick(function() {
  150. let code = this.diyInfo.bar_code;
  151. this.config.bar.code = code;
  152. this.config.qrc.code = code;
  153. })
  154. }else{
  155. toLogin();
  156. }
  157. },
  158. closeCode() {
  159. this.isCode = false
  160. this.isextension = false
  161. },
  162. tapCode(index) {
  163. this.codeIndex = index;
  164. if (index == 1) {
  165. this.getCode();
  166. } else {
  167. let code = this.diyInfo.bar_code;
  168. this.config.bar.code = code;
  169. this.config.qrc.code = code;
  170. }
  171. },
  172. goIntegral(){
  173. uni.navigateTo({
  174. url: '/pages/users/user_integral/index'
  175. })
  176. },
  177. goMoney(){
  178. uni.navigateTo({
  179. url: '/pages/users/user_money/index'
  180. })
  181. },
  182. goCoupon(){
  183. if(this.isLogin){
  184. uni.navigateTo({
  185. url: '/pages/users/user_coupon/index'
  186. })
  187. }else{
  188. toLogin();
  189. }
  190. },
  191. goLogin(){
  192. if(!this.isLogin){
  193. toLogin();
  194. }
  195. },
  196. getDiyUserInfo(){
  197. diyUserInfo().then(res=>{
  198. this.diyInfo = res.data;
  199. }).catch(err=>{
  200. this.$util.Tips({
  201. title: err
  202. });
  203. })
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. .userInfor {
  210. padding: 28rpx 20rpx;
  211. .mark {
  212. position: fixed;
  213. top: 0;
  214. left: 0;
  215. bottom: 0;
  216. right: 0;
  217. background: rgba(0, 0, 0, 0.5);
  218. z-index: 50;
  219. }
  220. .codePopup .icon-guanbi2{
  221. margin-top: 75rpx !important;
  222. }
  223. &.pageOn {
  224. border-radius: 12rpx;
  225. }
  226. .right {
  227. .item {
  228. text-align: center;
  229. font-weight: 400;
  230. color: #666666;
  231. font-size: 20rpx;
  232. margin-left: 32rpx;
  233. .num {
  234. font-size: 28rpx;
  235. margin-bottom: 4rpx;
  236. }
  237. }
  238. .iconfont {
  239. font-weight: 400;
  240. color: #333333;
  241. font-size: 30rpx;
  242. margin-bottom: 4rpx;
  243. }
  244. }
  245. .left {
  246. .pictrue {
  247. width: 90rpx;
  248. height: 90rpx;
  249. border: 1px solid #EEEEEE;
  250. border-radius: 50%;
  251. margin-right: 24rpx;
  252. image{
  253. width: 100%;
  254. height: 100%;
  255. border-radius: 50%;
  256. }
  257. }
  258. .text {
  259. font-weight: 400;
  260. color: #333333;
  261. font-size: 28rpx;
  262. .name{
  263. margin-bottom: 10rpx;
  264. }
  265. .progress{
  266. overflow: hidden;
  267. background-color: #EEEEEE;
  268. width: 144rpx;
  269. height: 14rpx;
  270. border-radius: 7rpx;
  271. position: relative;
  272. margin-right: 6rpx;
  273. .bg-reds{
  274. width: 0;
  275. height: 100%;
  276. transition: width 0.6s ease;
  277. background: linear-gradient(90deg, rgba(233, 51, 35, 1) 0%, rgba(255, 137, 51, 1) 100%);
  278. }
  279. }
  280. .percent{
  281. font-size: 20rpx;
  282. }
  283. .phone {
  284. font-weight: 400;
  285. color: #666666;
  286. font-size: 20rpx;
  287. margin-top: 6rpx;
  288. .iconshouji {
  289. margin-right: 4rpx;
  290. font-size: 24rpx;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. </style>