cards.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="pass-box">
  3. <en-nav ></en-nav>
  4. <view class="login-box" :style="{'height':'calc(100vh - '+navHeight+'px)'}" >
  5. <view class="login-top">
  6. <view class="login-title">
  7. <text class="title-item sys-color-black sys-weight-600">个性卡牌</text>
  8. </view>
  9. <view class="card-text">
  10. <text class="sys-color-gray-9">请使用本人</text>
  11. <text class="sys-color-green">真实照片</text>
  12. <text class="sys-color-gray-9">,否则部分功能可能会受限</text>
  13. </view>
  14. <view class="card-img" :class="{'open-img':imgBg}" @click="openPopup" :style="{'height':'calc(100vh - '+navHeight+'px - 278rpx - 270rpx - env(safe-area-inset-bottom)','background-image':'url('+imgBg+')'}">
  15. <view class="add-box" v-if="!imgBg">
  16. <image class="add-img" src="/static/img/common/add.png" mode="aspectFill"></image>
  17. </view>
  18. </view>
  19. <view class="card-agreement">
  20. <login-agreement :type="2" v-model="isCheck"></login-agreement>
  21. </view>
  22. </view>
  23. <view class="login-bottom">
  24. <view class="login-but sys-color-white sys-background-black sys-selected-but" @click="setNextStep" :class="{'sys-unselected-but':!isOK,'apply-shake':isShakeBut}">下一步</view>
  25. </view>
  26. </view>
  27. <en-popup ref="cardPopup">
  28. <template v-slot:popupInfo="{pagingData}">
  29. <view class="img-popup">
  30. <view class="popup-title sys-weight-600 sys-color-black">上传清晰的本人照片</view>
  31. <view class="popup-text sys-color-gray-9 ">
  32. 展示你真实有趣的一面
  33. </view>
  34. <view class="popup-img">
  35. <view class="popup-item">
  36. <image class="item-img" src="/static/img/perfect/img3.png" mode="widthFix"></image>
  37. <view class="item-describe">
  38. <image class="describe-img" src="/static/img/perfect/ok.png" mode="widthFix"></image>
  39. <view class="describe-text sys-color-white sys-weight-600" >半身/全身</view>
  40. </view>
  41. </view>
  42. <view class="popup-item">
  43. <image class="item-img" src="/static/img/perfect/img1.png" mode="widthFix"></image>
  44. <view class="item-describe">
  45. <image class="describe-img" src="/static/img/perfect/no.png" mode="widthFix"></image>
  46. <view class="describe-text sys-color-white sys-weight-600" >怼脸自拍</view>
  47. </view>
  48. </view>
  49. <view class="popup-item">
  50. <image class="item-img" src="/static/img/perfect/img2.png" mode="widthFix"></image>
  51. <view class="item-describe">
  52. <image class="describe-img" src="/static/img/perfect/no.png" mode="widthFix"></image>
  53. <view class="describe-text sys-color-white sys-weight-600" >网红非人</view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="popup-but sys-color-white sys-background-black sys-selected-but" @click="openChooseImage">从相册中选择</view>
  58. </view>
  59. </template>
  60. </en-popup>
  61. </view>
  62. </template>
  63. <script>
  64. import EnNav from "@/components/en-utils/en-nav/en-nav";
  65. import tools from "@/service/tools";
  66. import LoginAgreement from "@/pages/login/model/loginAgreement";
  67. import EnPopup from "@/components/en-utils/en-popup/en-popup";
  68. import cosServe from "@/service/txOssSts";
  69. import {setCard} from "@/api/login";
  70. export default {
  71. components: {EnPopup, LoginAgreement, EnNav},
  72. data() {
  73. return {
  74. navHeight:40,
  75. isOK:false,
  76. isShakeBut:false,
  77. nickname:'',
  78. password:'',
  79. imgList:[],
  80. imgBg:'',
  81. isCheck:false
  82. }
  83. },
  84. watch:{
  85. 'isCheck':function (){
  86. this.verifyIsOK()
  87. }
  88. },
  89. mounted() {
  90. tools.hideLoading()
  91. },
  92. methods: {
  93. openChooseImage(){
  94. uni.chooseImage({
  95. count: 6, //默认9
  96. sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
  97. sourceType: ['album'], //从相册选择
  98. success: (res) =>{
  99. console.log(res)
  100. if(res.tempFiles.length>0){
  101. console.log(res.tempFiles)
  102. res.tempFiles.forEach((item,key)=>{
  103. cosServe.txUploadFile(item,'gallery').then(async (res)=>{
  104. if(key===0){
  105. this.imgBg=res.Location
  106. this.imgBg=await cosServe.getSignUrl(this.imgBg)
  107. }
  108. this.imgList.push(res.Location)
  109. })
  110. })
  111. console.log( this.imgList)
  112. this.verifyIsOK()
  113. }
  114. this.$refs.cardPopup.close()
  115. }
  116. });
  117. },
  118. openPopup(){
  119. this.$refs.cardPopup.open()
  120. },
  121. setNextStep(){
  122. if(this.isOK){
  123. let mobile=uni.getStorageSync('mobile')
  124. setCard({'mobile':mobile,'cards':this.imgList}).then((res)=>{
  125. if(res.code===0){
  126. uni.switchTab({
  127. 'url':'/pages/index/index'
  128. })
  129. }else {
  130. tools.error(res.msg)
  131. }
  132. })
  133. }else {
  134. tools.error('请完善信息')
  135. this.isShakeBut=true
  136. setTimeout(()=>{
  137. this.isShakeBut=false
  138. },500)
  139. }
  140. },
  141. verifyIsOK(){
  142. this.isOK = this.isCheck && this.imgList.length>=0;
  143. },
  144. setNavHeight(navHeight){
  145. this.navHeight=navHeight+41
  146. },
  147. }
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. @import "/static/css/shake.css";
  152. .pass-box{
  153. .login-box{
  154. padding: 82rpx 80rpx 0 80rpx;
  155. box-sizing: border-box;
  156. position: relative;
  157. .login-top{
  158. .login-title{
  159. padding-bottom: 24rpx;
  160. .title-item{
  161. font-size: 48rpx;
  162. }
  163. }
  164. .card-text{
  165. padding-bottom: 16rpx;
  166. text{
  167. font-size: 28rpx;
  168. }
  169. }
  170. .card-img{
  171. width: calc(100vw - 160rpx);
  172. background: #F6F6F6;
  173. border-radius: 20rpx;
  174. position: relative;
  175. .add-box{
  176. position: absolute;
  177. top: 50%;
  178. left: 50%;
  179. transform: translate(-50%,-50%);
  180. .add-img{
  181. margin: auto auto;
  182. width: 84rpx;
  183. height: 84rpx;
  184. }
  185. }
  186. }
  187. .open-img{
  188. background-repeat: no-repeat;//不平铺
  189. background-position: center center;//居中
  190. background-size: cover;//随容器大小
  191. }
  192. .card-agreement{
  193. margin-top: 32rpx;
  194. }
  195. }
  196. .login-bottom{
  197. padding-bottom: calc(58rpx + env(safe-area-inset-bottom));
  198. position: absolute;
  199. bottom: 0;
  200. left: 68rpx;
  201. width:calc(100vw - 136rpx);
  202. .login-but{
  203. margin-top: 120rpx;
  204. }
  205. }
  206. }
  207. .img-popup{
  208. margin-top: 40rpx;
  209. padding: 0 32rpx calc(58rpx + env(safe-area-inset-bottom)) 32rpx;
  210. .popup-title{
  211. font-size: 36rpx;
  212. }
  213. .popup-text{
  214. padding: 16rpx 0 32rpx;
  215. font-size: 28rpx;
  216. }
  217. .popup-img{
  218. display: flex;
  219. justify-content: space-between;
  220. .popup-item{
  221. display: inline-block;
  222. margin-right:10rpx;
  223. position: relative;
  224. .item-img{
  225. border-radius: 16rpx;
  226. width: calc((100vw - 80rpx)/3);
  227. height: 276rpx;
  228. }
  229. .item-describe{
  230. position: absolute;
  231. left: 32rpx;
  232. bottom: 20rpx;
  233. width: calc((100vw - 80rpx)/3 - 64rpx);
  234. height: 36rpx;
  235. border-radius: 200rpx;
  236. background: rgba(0,0,0,0.6);
  237. display: flex;
  238. justify-content: flex-start;
  239. .describe-img{
  240. width: 36rpx;
  241. height: 36rpx;
  242. }
  243. .describe-text{
  244. margin-left: 8rpx;
  245. font-size: 24rpx;
  246. line-height: 36rpx;
  247. }
  248. }
  249. }
  250. .popup-item:nth-of-type(3n+0){
  251. margin-right:0;
  252. }
  253. }
  254. .popup-but{
  255. margin-top: 58rpx;
  256. }
  257. }
  258. }
  259. </style>