userInfor.vue 8.4 KB

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