index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }"
  3. :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  4. <tm-menubars title="衣物录入" :shadow="0" :showback="true"></tm-menubars>
  5. <div class="zhuti">
  6. <tm-sheet class="kuang" style="padding-bottom: 70px !important;">
  7. <image v-if="active==1" class="jindu" src="/static/img/49.png" mode="widthFix"></image>
  8. <image v-if="active==2" class="jindu" src="/static/img/50.png" mode="widthFix"></image>
  9. <image v-if="active==3" class="jindu" src="/static/img/51.png" mode="widthFix"></image>
  10. <view class="wenzi flex-between flex-center" style="margin-top: 10px;">
  11. <view>
  12. <text class="text-white text-size-m">衣物拍照</text>
  13. </view>
  14. <view>
  15. <text class="text-white text-size-m">确认衣物属性</text>
  16. </view>
  17. <view>
  18. <text class="text-white text-size-m">入库成功</text>
  19. </view>
  20. </view>
  21. <view v-if="active==1">
  22. <view class="mt-20 ml-15">
  23. <text class="text-white text-size-m">*衣物拍照实例图</text>
  24. </view>
  25. <image block class="zhanshi" mode="widthFix" src="/static/img/48.png"></image>
  26. <tm-button :round="24" class="mb-40" @click="paizhao()" block>拍照录入</tm-button>
  27. </view>
  28. <view v-if="active==2">
  29. <image block class="nicheng" mode="widthFix" :src="koutu"></image>
  30. <view class="you black mt-30">
  31. <tm-input title="衣长" v-model="reqData.username" align="right"></tm-input>
  32. <tm-input title="上市年份" v-model="reqData.height" align="right"></tm-input>
  33. <tm-input title="颜色" v-model="reqData.weight" align="right"></tm-input>
  34. <tm-input title="尺码" v-model="reqData.username" align="right"></tm-input>
  35. <tm-input title="品牌" v-model="reqData.height" align="right"></tm-input>
  36. <tm-input title="主材含量" v-model="reqData.weight" align="right"></tm-input>
  37. <tm-input title="适用对象" v-model="reqData.weight" align="right"></tm-input>
  38. </view>
  39. <tm-button :round="24" class="sao mb-40 mt-40" @click="chuangjianFun()" block>下一步</tm-button>
  40. </view>
  41. <view v-if="active==3">
  42. <tm-translate ref="a_1" :auto="true" animation-name="zoomIn">
  43. <image block class="nicheng" mode="widthFix" src="/static/img/52.png"></image>
  44. </tm-translate>
  45. <view class="text-align-center mt-20">
  46. <text class="text-size-m text-white">衣物添加成功!</text>
  47. </view>
  48. <view class="text-align-center mb-40">
  49. <text class="text-size-m">您可以在我的衣柜中添加或删除衣物</text>
  50. </view>
  51. <view class="px-24">
  52. <tm-button @click="jixu()" :round="24" block class="mt-50 logincla">继续添加衣物</tm-button>
  53. <tm-button @click="quindex()" theme="primary" :round="24" block class="mt-30 quindex">进入衣柜</tm-button>
  54. </view>
  55. </view>
  56. </tm-sheet>
  57. </div>
  58. <!-- 弹出层消息 -->
  59. <tm-message ref="toast"></tm-message>
  60. </view>
  61. </template>
  62. <script>
  63. import{myRequest} from '@/api/request.js'
  64. import { pathToBase64, base64ToPath } from '@/js_sdk/mmmm-image-tools/index.js'
  65. export default {
  66. data() {
  67. return {
  68. reqData:{
  69. username:'1',
  70. height:'1',
  71. weight:'1',
  72. },
  73. koutu:'/static/img/53.png',
  74. shencaiList:[
  75. {title:"梨形",id:21},
  76. {title:"标准",id:31},
  77. {title:"胖子",id:41},
  78. {title:"瘦子",id:51},
  79. {title:"模特",id:61},
  80. ],
  81. shenxing:'',
  82. active:1,
  83. name:'',
  84. chelianglis:[
  85. {title:"标准",id:21},
  86. {title:"偏瘦",id:31},
  87. {title:"偏胖",id:41},
  88. {title:"梨形",id:51},
  89. {title:"S型",id:61},
  90. ],
  91. reqData:{
  92. username:'',
  93. height:'',
  94. weight:'',
  95. shencai:[]
  96. },
  97. renList:[]
  98. };
  99. },
  100. onLoad() {
  101. },
  102. created() {
  103. this.sys = uni.getSystemInfoSync();
  104. this.add()
  105. },
  106. methods: {
  107. jixu(){
  108. this.active=1;
  109. },
  110. quindex(){
  111. // uni.setStorageSync("index",1)
  112. // this.$emit('fatherMethod', )
  113. uni.navigateTo({
  114. url: "/pages/index/index?index=1",
  115. })
  116. },
  117. tijiao(){
  118. // console.log(this.renList)
  119. // for(let i=0;i<this.renList.length;i++){
  120. // if(this.renList[i].){}
  121. // }
  122. // this.active=4;
  123. },
  124. add(){
  125. var timestamp = Date.parse(new Date());
  126. var obj={
  127. username:'',
  128. height:'',
  129. weight:'',
  130. shencai:[],
  131. timestamp:timestamp
  132. }
  133. this.renList.push(obj)
  134. },
  135. shanchu(timestamp){
  136. var index = this.renList.findIndex((item) => {
  137. return item.timestamp == timestamp;
  138. });
  139. this.renList.splice(index, 1);
  140. },
  141. obTstr2(o){
  142. if(Array.isArray(o)){
  143. if(o.length.length===0) return "";
  144. return o[0]?.title??""
  145. }
  146. return ''
  147. },
  148. paizhao(){
  149. var that=this;
  150. uni.chooseImage({ //uni官方api,用于选取本地图片
  151. count: 1, //默认9
  152. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  153. sourceType: ['album','camera'], //从相册选择
  154. success: function (res) {
  155. that.imgpath = res.tempFilePaths[0] //先获得本地文件的路径列表,存储到数组
  156. console.log(that.imgpath) //注意该api会将路径转换为blob格式
  157. that.getBase64Image(that.imgpath);
  158. }
  159. })
  160. },
  161. getBase64Image(path){
  162. var that=this;
  163. console.log(" 开始转换")
  164. pathToBase64(path)
  165. .then(base64 => {
  166. that.shibie(base64)
  167. })
  168. .catch(error => {
  169. console.error(error)
  170. })
  171. },
  172. shibie(src){
  173. var that=this;
  174. // 抠图
  175. uni.request({
  176. url: 'https://objseg.market.alicloudapi.com/commonseg/rgba',
  177. method : "post",
  178. header: {
  179. 'Authorization':'APPCODE e4b9accfb1f246cb8c0766a54efe8730',
  180. "Content-Type":"application/json;charset=UTF-8"
  181. },
  182. data:{
  183. photo:src
  184. },
  185. success : function(data) {
  186. console.log(data)
  187. that.koutu=data.data.data.result
  188. that.active=2;
  189. },
  190. error : function(e) {
  191. alert("网络异常,请重试");
  192. }
  193. });
  194. },
  195. chuangjianFun(){
  196. var that=this;
  197. // if(that.name==""){
  198. // that.$refs.toast.show({model:'warn',label:'请输入家庭名称'})
  199. // return
  200. // }
  201. that.active=3;
  202. }
  203. },
  204. }
  205. </script>
  206. <style lang="scss">
  207. .zhanshi{
  208. width: 100%;
  209. margin: 0 auto;
  210. margin-top: 10px;
  211. margin-bottom: 40px;
  212. }
  213. /deep/ .tm-menubars .body{
  214. background-color: #1b1b1b !important;
  215. }
  216. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  217. // /deep/ .kuang uni-button{background-color: #303440 !important;}
  218. .jindu{width: 90%;margin: 0 auto;display: block;}
  219. .wenzi{width: 94%;margin: 0 auto;}
  220. .nicheng{width: 60%;display: block;margin:0 auto;margin-top: 50px;}
  221. /deep/ .shuru .grey-darken-5{
  222. background-color: #0d0d0d!important;
  223. padding: 0px !important;
  224. }
  225. .shuru{border:1px solid #303030;border-radius: 10px;}
  226. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  227. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  228. .zuo image{width:60px;display: block;}
  229. .you{border:1px solid #303030;border-radius: 10px;padding:10px;}
  230. /deep/ .you .grey-darken-5{
  231. background-color: #0d0d0d!important;
  232. padding: 0px !important;
  233. }
  234. /deep/ .you .text-red{color: white;}
  235. /deep/ .tan .active{background-color: #AAAAAA !important;}
  236. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  237. /deep/ .tan uni-input{text-align: right;}
  238. /deep/ .you .border-grey-darken-4-b-1 {
  239. border-bottom: solid 1px #313131 !important;
  240. }
  241. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  242. .logincla{margin-top: 100px;}
  243. /deep/ .logincla .primary{background-color: #303440 !important;}
  244. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  245. </style>