index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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:3,
  83. name:'',
  84. val_1:'',
  85. chelianglis:[
  86. {title:"标准",id:21},
  87. {title:"偏瘦",id:31},
  88. {title:"偏胖",id:41},
  89. {title:"梨形",id:51},
  90. {title:"S型",id:61},
  91. ],
  92. reqData:{
  93. username:'',
  94. height:'',
  95. weight:'',
  96. shencai:[]
  97. },
  98. renList:[]
  99. };
  100. },
  101. onLoad() {
  102. },
  103. created() {
  104. this.sys = uni.getSystemInfoSync();
  105. this.add()
  106. },
  107. methods: {
  108. jixu(){
  109. this.active=1;
  110. },
  111. quindex(){
  112. // uni.setStorageSync("index",1)
  113. // this.$emit('fatherMethod', )
  114. uni.navigateTo({
  115. url: "/pages/index/index?index=1",
  116. })
  117. },
  118. tijiao(){
  119. // console.log(this.renList)
  120. // for(let i=0;i<this.renList.length;i++){
  121. // if(this.renList[i].){}
  122. // }
  123. // this.active=4;
  124. },
  125. add(){
  126. var timestamp = Date.parse(new Date());
  127. var obj={
  128. username:'',
  129. height:'',
  130. weight:'',
  131. shencai:[],
  132. timestamp:timestamp
  133. }
  134. this.renList.push(obj)
  135. },
  136. shanchu(timestamp){
  137. var index = this.renList.findIndex((item) => {
  138. return item.timestamp == timestamp;
  139. });
  140. this.renList.splice(index, 1);
  141. },
  142. obTstr2(o){
  143. if(Array.isArray(o)){
  144. if(o.length.length===0) return "";
  145. return o[0]?.title??""
  146. }
  147. return ''
  148. },
  149. paizhao(){
  150. var that=this;
  151. uni.chooseImage({ //uni官方api,用于选取本地图片
  152. count: 1, //默认9
  153. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  154. sourceType: ['album','camera'], //从相册选择
  155. success: function (res) {
  156. that.imgpath = res.tempFilePaths[0] //先获得本地文件的路径列表,存储到数组
  157. console.log(that.imgpath) //注意该api会将路径转换为blob格式
  158. that.getBase64Image(that.imgpath);
  159. }
  160. })
  161. },
  162. getBase64Image(path){
  163. var that=this;
  164. console.log(" 开始转换")
  165. pathToBase64(path)
  166. .then(base64 => {
  167. that.shibie(base64)
  168. })
  169. .catch(error => {
  170. console.error(error)
  171. })
  172. },
  173. shibie(src){
  174. var that=this;
  175. // 抠图
  176. uni.request({
  177. url: 'https://objseg.market.alicloudapi.com/commonseg/rgba',
  178. method : "post",
  179. header: {
  180. 'Authorization':'APPCODE e4b9accfb1f246cb8c0766a54efe8730',
  181. "Content-Type":"application/json;charset=UTF-8"
  182. },
  183. data:{
  184. photo:src
  185. },
  186. success : function(data) {
  187. console.log(data)
  188. that.koutu=data.data.data.result
  189. that.active=2;
  190. },
  191. error : function(e) {
  192. alert("网络异常,请重试");
  193. }
  194. });
  195. },
  196. chuangjianFun(){
  197. var that=this;
  198. // if(that.name==""){
  199. // that.$refs.toast.show({model:'warn',label:'请输入家庭名称'})
  200. // return
  201. // }
  202. that.active=3;
  203. }
  204. },
  205. }
  206. </script>
  207. <style lang="scss">
  208. .zhanshi{
  209. width: 100%;
  210. margin: 0 auto;
  211. margin-top: 10px;
  212. margin-bottom: 40px;
  213. }
  214. /deep/ .tm-menubars .body{
  215. background-color: #1b1b1b !important;
  216. }
  217. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  218. // /deep/ .kuang uni-button{background-color: #303440 !important;}
  219. .jindu{width: 90%;margin: 0 auto;display: block;}
  220. .wenzi{width: 94%;margin: 0 auto;}
  221. .nicheng{width: 60%;display: block;margin:0 auto;margin-top: 50px;}
  222. /deep/ .shuru .grey-darken-5{
  223. background-color: #0d0d0d!important;
  224. padding: 0px !important;
  225. }
  226. .shuru{border:1px solid #303030;border-radius: 10px;}
  227. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  228. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  229. .zuo image{width:60px;display: block;}
  230. .you{border:1px solid #303030;border-radius: 10px;padding:10px;}
  231. /deep/ .you .grey-darken-5{
  232. background-color: #0d0d0d!important;
  233. padding: 0px !important;
  234. }
  235. /deep/ .you .text-red{color: white;}
  236. /deep/ .tan .active{background-color: #AAAAAA !important;}
  237. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  238. /deep/ .tan uni-input{text-align: right;}
  239. /deep/ .you .border-grey-darken-4-b-1 {
  240. border-bottom: solid 1px #313131 !important;
  241. }
  242. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  243. .logincla{margin-top: 100px;}
  244. /deep/ .logincla .primary{background-color: #303440 !important;}
  245. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  246. </style>